Unity3D Optimization Trigger Collider vs Squared Distance

Viewed 65

I have multiple objects (waypoints). I want to determine which waypoint my player (which is a constantly moving ball) is closest to. Should I use collider with IsTrigger turned on and use OnTriggerEnter() Or do I calculate distance of player in a script attached to each waypoint and check which waypoint is closest to the player ? Which one is faster ?

1 Answers

I think that the manual [sqr] distance check would be more appropriate. I'm not 100% sure, but I think that the trigger colliders still have to do some distance calculations each frame to detect if something overlaps them. When using a simple manual [sqr] distance checks you are avoiding the additional computational overhead of the trigger colliders.

Related