Performance: OnTriggerEnter or OverlapSphere

Which one is more efficient?
OverlapSphere
or a OntriggerEnter and OntriggerExit updating an array

?

Only diff. i can tell is what is checked against in Ontrigger its checking the collider on overlap shpere its checking the bounding volume. but still checks have to be made.

I would think OverlapShpere is best if you are having alot of mesh colliders as the bounding volume is just a box, but dont know is just my guess.

Enter stage: Testing

Are you sure that overlap sphere checks the bounding volume? I’m pretty sure that overlap sphere checks the actual colliders. (Just like OnTrigger)

Yes OverlapSphere checks bounding volumes.

So for AI you’re better off using OverlapSphere.

I think I should clarify my question:
When I use ontriggerenter/exit, I’m the one managing addition of new colliders in an array
when using overlapSphere I’m wondering if the list is rebuilt from scratch or if physx buffers what it’s found and only updates the newcomers (hence reaching the same efficiency as ontriggerenter/exit) or if it is too insignificant (around 200 object at all time will fluctuate)

I did a little test. It debugs a message when there is a collider in a Physics.OverlapSphere (). It doesn’t seem to debug a message when the collider’s bound is within the radius, but only when the actual collider is. What do you think?

81730–3161–$overlap_test_183.zip (609 KB)

Its in the API what OverlapSphere uses :smile: