Let’s Get Physics-al: OnCollisionEnter Vs. OnTriggerEnter — When to use them?

The ball on the left is using OnCollisionEnter and the ball on the right is using OnTriggerEnter

Let’s get physical with Unity’s physics engine and to be more specific the OnCollisionEnter and OnTriggerEnter feature. Here is the difference between the two:

  1. OnCollisionEnter — is to be used when you want the two objects colliding with each to be solid and have physics acting upon them.
  2. OnTriggerEnter — is to be used when you just want to detect a collision and not have the object interact at all with each other.

The image above is an example of the two different Enter methods. The ball on the left is showing an OnCollisionEnter. Every time the ball collides with the ground each changes color to show the OnCollisionEnter. Notice how the physics is being applied when the ball hits the ground. The ball on the right is a little different. It has OnTriggerEnter so it travels through the platform and there are no physics applied. It is a ghost. The ball changes color to show each time an OnTriggerEnter happens.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store