OnCollisionEnter Vs OnTriggerEnter

Rook Sullivan
Apr 6, 2021

--

Unity has two separate kinds of collisions; Hard Surface collision and Trigger collision. A hard surface collision would be a physical collision between objects, where physics would be applied. Examples include a car crash, a bullet ricochet, and a ball bouncing off a wall.

Trigger collisions are where objects touch and it causes something in the game to happen, like collecting a powerup or collectable or entering a loading zone / cutscene trigger. Trigger collisions pass through the object without physically interacting with the object, giving the illusion of interacting with it.

OnCollisionEnter could thus be used to tell a baseball to bounce off the bat, and apply momentum to the object in a direction based on where the objects collided. OnTriggerEnter could be used to pick up a fire flower in mario and apply the appropriate powerup to the player.

--

--

Rook Sullivan
Rook Sullivan

Written by Rook Sullivan

Non-binary game dev sharing my experiences in Unity.

No responses yet