OnCollisionEnter vs. OnTriggerEnter and when to use them

Come together.

This is just a very brief article to help you distinguish between OnCollisionEnter and OnTriggerEnter. The two are triggered by the same circumstance: the interaction between two colliders. But they report different facts about that event.

OnTriggerEnter requires the Collider component of the object to have “is trigger” enabled. When this option is selected, Unity will ignore physics for this object. When this object’s collider box (now a trigger box) touches another collider, it returns the other object in the collision to OnTriggerEnter. You can use this information in script to create an infinite range of conditional events.

When the object’s collider encounters another collider, OnCollisionEnter returns the Collision class. The Unity physics engine calculates a number of qualities, such as contact points, velocity, impulse, etc. and stores those as properties within the Collision class. This is useful if you’re simulating detailed physical interactions.

In short: OnTriggerEnter is for non-physics-calculating interactions between colliders. OnCollisionEnter is for physics-calculating interactions between colliders.

In the next article, we’ll go over script communication in Unity using GetComponent.