Find object in range VS using colliders

by Alexandre Beaudet   Last Updated October 11, 2018 15:13 PM

For a game I'm currently working on, I need to retrieves every interactable object in a certain range from the player's camera.

There's two way that I can think of :

  • Using find object with tag, and retrieving the distance for each objects
  • Using a large collider either around the camera, or around each interactable objects

The first one seems really bad performance wise, since you could be retrieving quite a lot of objects, and you'd have to compute the distance every frame

The second one seems better, but it also means that anything entering the collider range will be tag-tested

The third one might be the best in my opinion, since interactable object won't move around the collision should only happen with the player / some moving objects

Considering the range is fairly large, which solution would be the most pertinent / easy on performances ?

Thanks !

Edit : The only resource I found seems to go towards the collision detection, but nothing to back the point of view of this guy => https://forum.unity.com/threads/find-object-with-tag-in-range.190938/

Tags : unity collider


Related Questions


Unity: Messages in Compound Colliders

Updated July 27, 2017 01:13 AM

Fixing collider for existing scene

Updated April 21, 2017 15:13 PM



Unity3d How to add collider to borders

Updated September 28, 2018 18:13 PM