Hi,
I’m trying to find all the gameobjects that are within range of the current collider. I don’t want to use event-handling methods like OnTriggerXXX/OnCollisionXXX, and I don’t want any of the objects to have rigidbodies either. All I want is given a collider, find all the other colliders that overlap it.
The closest thing I know of is Physics.OverlapSphere, but it’s limited to a sphere shape. I’d like to do something very similar with a collider.
Any ideas?
Well you know the size of the object and it's position. You could check if two objects are within' eachothers size area and position. Though, may I ask, why don't you want to use rigidbodies or colliders or OnCollision/Trigger?
– jacobschellenbergYou could do the Physics.OverlapSphere() first, then do the Bounds.Intersect() for anything it finds. It is probable that under the hood, Unity is iterating through all the colliders with OverlapSphere(), so it might not buy you anything. That is, if you do a distance check in your loop before you do the Bounds.Intersect() you may have similar performance.
– robertbu