Issues with Removing Objects from MapLayer using Lightship SDK

  • Issue category: Lightship Maps
  • Host machine & OS version: Mac / Windows / Linux / Other Ex. Mac on Big Sur x.x
  • Issue Environment : Unity Remote / Unity Mock / On Device / Dev Portal

Description of the issue:

I’ve encountered an issue while using the Lightship SDK, specifically with the PlaceInstance method. I’m successfully spawning objects on the MapLayer using PlaceInstance(). However, I’m struggling with removing these objects.

When I attempt to delete an object using Destroy and move a significant distance away, the object doesn’t seem to get removed from the ObjectPool. This lingering presence of the object is causing some complications in my application.

Could anyone guide me on how to properly remove objects from the MapLayer? What are the best practices for ensuring that objects are completely deleted from the ObjectPool and do not persist in the map environment?

Hey there,

Firstly, you need to keep track of the PooledObject structure that handles transactions with the ObjectPool your object is apart of. You can get that structure from the ObjectPool#OnAcquire(PooledObject<T>) event ( When you’re done with your object, you need to call PooledObject#Dispose() ( prior to calling #Destroy() or, better yet, call PooledObject#Dispose() from OnDestroy().

Kind regards,
Maverick L.