A Tale of Two Colliders-Triggers vs Collisions in Unity

Adding a Rigidbody in Unity is enough to enable physics but it isn’t if you want interactions between objects.

Any object that requires some form of interaction needs a collider component. There are many presets in Unity that you can use to fit your needs:

If we have a cube, we would most likely want to add a “Box Collider”:

Clicking on the button next to “Edit Collider” allows you to adjust the size of your collider:

The Collider option “Is Trigger” is what dictates whether the object should pass through or collide with another object.

An example of when you would want a trigger would be when you want to detect if a player has reached a certain point, but not prevent them from moving forward.

Conversely, you would uncheck the “Is Trigger” if you want a physical barrier, like a wall, which would stop another object.

Within a Unity script, both types have their own methods for accessing them.

For passive interactions in 3D, here are 3 methods you can use:

There are 2D version of these as well

OnTriggerEnter is called when the overlap of colliders begins.
OnTriggerExit is called when the overlap of colliders ends.
OnTriggerStay is called while both colliders remain overlapped.

For physical interactions, there are also 3 methods:

In all circumstances, the “other” argument refers to the collider of the external object that is in contact with the object owning the script.

A use case example would be if you wanted to destroy an object that comes into contact with the player:




Unity Developer

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Fault Policy SOA Suite 11g — Configuration and Deployments

AWS Windows EC2 instance resource alerting (CPU/Memory/Disk) without Cloudwatch

Effective Communication With Remote Developer Teams

Parsing SQL Queries For Table Names

A table and single chair in a white room.

Top 5 Project Tracking Tools for Managers and Startupers

SupraOracles Discrod Tour

The Two Most Important CSS Concepts to Understand

The Challenges of Managing Stakeholder Alignment for Application Success

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
Mike Brisson

Mike Brisson

Unity Developer

More from Medium

Adding Shield Strength And Color Change When Damaged And Tying It To UI Sprite Sheet

Space Craft Effects

Creating Elevator in Unity — Part 3: Moving Elevator.

Hidden Shortcuts to Make Level Design Easier in Unity.