Use collisions to trigger other events
Overview of collision events and triggers, and the scripting API you need to use.
Read time 1 minuteLast updated a month ago
When two colliders make contact, they call functions that you can use to trigger other events in your project. You can place any code you like in these functions to respond to the collision event.
Collider events require configuration via C# script; you cannot configure them using only the user interface.
There are two collider event types:
- Collision events: Collision events occur when two colliders make contact, and neither collider has Is Trigger enabled. The most common collision functions are ,
Collider.OnCollisionEnter, andCollider.OnCollisionStay.Collider.OnCollisionExit - Trigger events: Trigger events occur when two colliders make contact, at least one collider has Is Trigger enabled, and at least one collider has a Rigidbody or ArticulationBody. The most common trigger functions are ,
Collider.OnTriggerEnter, andCollider.OnTriggerStay.Collider.OnTriggerExit
A collider that has Is Trigger enabled is called a trigger collider. Trigger colliders do not physically collide with other colliders; instead, they create a space that sends an event when other colliders pass through it.
Note: The 2D physics system has equivalent functions with 2D appended to the name (for example, ). For details of these 2D functions, refer to the API class documentation.
OnCollisionEnter2DMonoBehaviour