Day 12:OnCollisionEnter Vs. OnTriggerEnter — When to use them?

Tyler Smallwood
2 min readMay 4, 2021
Player interacts while Enemy falls though.

For the Physic system there are different ways objects interact with each other. In code we have options for OnCollisionEnter and OnTriggerEnter.

OnCollisionEnter

This will be used if the interaction will a collision. Say if every time the player runs into a wall, the wall will stop the player but also change colors.

OnTriggerEnter

OnTriggerEnter will act as a trigger. This could be used to start cut screens, spawn monsters when you walk to a certain area, or add some effect as if two objects collide and explode.

There are more options than just Enter, there is also Stay and Exit.

OnTriggerEnter, OnTriggerStay, OnTriggerExit, OnCollisionEnter, OnCollisionStay, and OnCollisionExit.

Enter will run as soon as you collide with an object or enter the area of the trigger.

Stay will run like a loop while you stay collided or in the area.

Exit will run as soon as you stop colliding and leave the exit.

--

--

Tyler Smallwood

I am passonate on learning to program and use Unity to become a skillful Unity Developer