Unity3D Basics — Driving Head-First into Collisions

Claudio Grassi
5 min readMar 30, 2021

Previously we discussed the basics of Unity’s physics engine. Now we will take a quick look at collisions.

Collisions are the events that happen in Unity when two or more objects in the scene that are equipped with Colliders and Rigid Bodies come into contact or overlap in space.

Unity provides us with two main types of collision methods that assist us in scripting behaviors and interactions:

I will preface this by saying that there are a few more methods related to Collider events both for 3D and 2D physics and I will briefly mention them later. For now, I want to focus on these two.

The main difference you may notice beyond their name is the parameter that each method takes.

  • OnCollisionEnter() takes a Collision type parameter that can give us information on Contact points or the velocity at which the collision took place. This is because the event gets detected at the point of contact between two or more colliders. For this method to work, the object that detects the event must have a Rigid Body attached to it.
  • OnTriggerEnter() takes a Collider type parameter…

--

--

Claudio Grassi

Experienced digital artist, Unity game developer & coder with a knack for problem solving and a passion for video games.