I have a bunch of GameObjects in a scene. I need each GameObject to know the location and rotation of its neighbours (within a certain range). What is the best and fastest way to find the location and rotation of a GameObject’s neighbours within a certain range? Can someone provide an example? Thanks in advance!
2 Answers
2Physics.SphereCast centered on the core object to get a list of objects in range, then grab these object’s transforms
What you are looking for is :
Physics.OverLapSphere
Basically creates a sphere collider for a single frame and checks to see if it collided with anything, you would need to make the objects you are checking against have colliders, but it is also possible to give them triggers if that is not what you want to do. (Detail in the docs on how to do this).
What @JC_SummitTech said is also viable.
I understand your question, but what exactly are you trying to do? A bit more context would be appreciated
– Spartiate0033