Error: NullReferenceException: Object reference not set to an instance of an object

Include the following details (edit as applicable):

  • Issue category: Lightship Maps
  • Device type & OS version: iOS
  • Host machine & OS version: Windows
  • Issue Environment : Unity Remote
  • Xcode version:
  • ARDK version:
  • Unity version: 2021.3.37f1

Description of the issue:
Just learned about lightship not long ago and trying to test it out over mapbox. When trying to test with Unity Remote, I get this error when trying to run on my iphone to test the location and just the empty scene (no map gets generated, character is in emptiness).

NullReferenceException: Object reference not set to an instance of an object
Niantic.Lightship.Maps.LightshipMapView.SetMapCenter (UnityEngine.Vector3 center) (at Library/PackageCache/com.niantic.lightship.maps@633b3bbcda9e/Runtime/Niantic.Lightship.Maps/LightshipMapView.cs:282)

The line in question is

// Update the map’s view based on where our player is
_lightshipMapView.SetMapCenter(transform.position);

I have tried tweaking it to no avail. I thought maybe it was because locationServices wasnt getting started, but it seems the file does this once it determines the application isnt running in editor. I also have location services enabled for unity remote. How do I get it to work with my phones location?

Also because im sure this will be asked as it would seem this would be the issue, but yes I have the Lightship Map View on the Player set in the editor to the scenes LightshipMap object, so its not because that isnt set.

Edit: After browsing some other posts, it seems it might be because when unchecking the default start position, the _unitConverter doesnt get initialized. The issue with this, is when the default start position is checked, it doesnt ever seem to update to my phones location, it just stays at the start position. I cant move or anything, i can move the camera but not that player

Hi Nolan,

There’s a longstanding bug with Maps where you MUST enable “Start at Default Location” or certain components of it – specifically the unit converter – will not be instantiated properly. Looking at the code, I believe that is the source of your NullReferenceException.

Kind regards,
Maverick L.

Yes, I ended up making some modifications to some of the files to end up getting it all working as well as some player rotation bases on the device compass, not sure if its done efficiently or properly, but at the moment it works. Thank you for getting back to me though

This topic was automatically closed 2 hours after the last reply. New replies are no longer allowed.

I’m glad you got it all sorted out!