Introduction to Physics in Unity’ & ‘OnCollisionEnter Vs. OnTriggerEnter — When to use them?

Renato Figueiredo
2 min readNov 30, 2023

Objective: Learn how Physics works in Unity, and the difference type of Collisions.

How does Physics works in Unity ? Well, in order for us to properly use it, we first need a GameObject with a Rigidbody, that allows us to use collisions, and a Collider, for us to check said collision.

Both Collider and Rigidbody attached to a GameObject in Unity.

With this combination, now we can apply Physics and Collision to our GameObject. That means we can stop at walls, push objects, and have other interactions with Physics via this combination.

OnCollisionEnter

There are 2 types of collision in Unity. The first one is what we call a surface collision, and that uses our OnCollisionEnter method. This happens when you throw a ball at a wall, and the ball bounces back.
This should be used, when you want your GameObjects to interact with each other, such as bumping into another player in a racing game. Or maybe shoving or pushing an enemy in FallGuys.

OnTriggerEnter

The second type is what we call a trigger-collision, and that uses the OnTriggerEnter method. This second collision is generally used for collecting something, such as coins, power-ups and other collectable items in games.
This one is best represented in most Platform games, such as collection coins in Mario, or collecting a power-up in Mario Kart.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

No responses yet

Write a response