Getting Started With Collision Detection in Unity

Ben Pielstick
2 min readMar 27, 2021

Detecting collisions is another relatively fundamental game engine feature. Unfortunately not all implementations are very easy to use, since some engines rely on third party solutions such as Havok, and PhysX by Nvidia, which don’t always integrate nicely with the native engine features.

Although you can integrate Havok into Unity, and probably should if you need accuracy and performance, the basic Unity physics solution works pretty well, and is much easier to use.

To get started using native Unity physics, all you have to do is add a Rigidbody component to any game object. Notably only one object needs this component to detect a collision with any other object that has a collider of some sort, which most objects should support if they have any kind of renderable.

This is all it takes to get physics collisions going

Within each collider there is a flag to set an object as a trigger volume, which is handy for any time you want to detect something in a radius rather than cause two things to run into each other.

Is Trigger is an important flag not to miss!

Once you set up your objects in the scene, all you have to do is make a few quick API calls and you’ll be able to detect collisions and use them for whatever game features that you need.

Yep, it’s that easy

There are definitely enough features in Unity’s built in physics to make an entire game without resorting to third party options. How well this might scale based on your needs might be something to test, but for most basic games that don’t require a lot of physics, these features should do fine.

--

--

Ben Pielstick

Game developer with over 12 years of experience, mainly focused on MMOs.