Collisions in Unity require two things, that both objects have a collision box, and that at least one of the objects has a rigidbody.

When such two objects collide, the object with a rigidbody behaves as you would expect from a physical object, while an object without a rigidbody is considered static and remains perfectly in place. Additionally, Unity generates events when collisions occur, which can be hooked into by scripting.

Above is shown the Unity collision matrix, showing when trigger events and collision events are detected and can be reacted to inside a script.

Trigger events require one or both of the objects to have the “Is Trigger” check box checked

Above is collision handling for an enemy in a simple 2D space arcade shooter. Using the Unity tag system to identify what the enemy has collided with, it can react accordingly to the collision event. Enemies are the only objects with a rigidbody and all colliders are set to triggers.

But what if I change to having rigidbodies on both lasers and enemies, and uncheck “Is Trigger”?

Now the enemies and lasers just get knocked off course!?

Because the script is still only hooked up to trigger collisions, easy fix.

Note the change to the Collision type from the Collider type, which contains information about the collision itself.

Now the game is behaving the same as it did originally, but adding additional rigidbodies to the game is only going to slow it down, computationally, even if the rigidbodies aren’t being used to simulate any movement.

Masters graduate of Learning and experience technology from University of southern Denmark, with a passion for the future of interaction.