I would like to add some important information related to this :
Getting distance X times per a specific amount of time should be priories when :
• If you plan on having multiple Triggers zones overlapping each others.
There are many issues with the Tiggers colliders in Unity (even Unity 5). One being that having too many calls from collisions can end up with some triggers being ignored.
• If some Trigger collider might be in contact with multiple none-trigger colliders. This is another issue with Unity. Having a trigger collider from which some none-trigger colliders intersect too much of its “zone” can add a kind of glitchy collision to the trigger itself. Whenever I put a trigger collider and it has around 2/3 or more of its “zone” covered with none-trigger colliders, anything with a Character Controller seems to bounce off from it through not completely (the trigger still works, but well… you can’t move within the zone anymore).
• If you require a trigger that is really big. While “zoning” can be done with triggers, a problem with triggers is that they are still getting their checkup on every OnTriggerEnter(), OnTriggerStay(), OnTriggerExit() even if those aren’t used. It also create an interne list of whatever is within it. Triggers can’t be turned into stand-by unless turned off. You can’t have control over the “refreshing rate” of the checks either. Whenever any collider or Character Controller enter or stay or exit a trigger collider, its functions are called at every frame even if empty. So, a big zone will mostly be called every frame since the chance of it having absolutely no colliders within might never be real.
• If your zoning/collision trigger is either a sphere or especially rectangle prisme or square prisme. As you can controls such “zone” with ease (Make use of a radius or 3 sizes) and do a check on specific target at specific point of time. Even better, you can actually build a list of asset (and update it) from which the “zone” can look at and get whatever it needs to check. In other words, recycling a maybe-already-existing list you might have created for another purpose.
• If your zone is moving. Trigger zone that moves requires a Rigidbody… and rigidbodies, while optimized, still take a lot memory more than a raycast. Triggers that aren’t with a Rididbody but still move is really taking a toll on the memory because every time it move, it’s trigger is getting reconstructed at the new position while, with a rigidbody, the “center” zone of the trigger is based on the rigidbody’s physic system.
Trigger colliders could be useful for :
• You require a really specific and complex form for the trigger zone. Well, if you require a zone that is quite complex and precise, it’s quite a better option than doing a kind of insane amount of raycast from many points with different distance and all. (For example, a laser grid-like trigger zone with a bunch of specific complex sized holes for the player to move in)
• For area with little chances existing collision. For example, the transition zone at the edge of a map could be launched from a Trigger collision. As you can make the trigger zone into the air and leave the open transition zone empty from anything. (Not necessary fully empty, but leaving a “slice” of space empty which will include the trigger zone.
• If you requires to get data from the trigger. It’s surely more simple to get the data from the trigger’s collision than doing it from a series of raycast since triggers (as well as collider) register any points of entry or exit from other collider (the good side of the 3 previously mentioned functions that are automatically called).
Those are the general points about whenever you should check distance or use a Trigger Collider.