When two collidersAn invisible shape that is used to handle physical collisions for an object. A collider doesn’t need to be exactly the same shape as the object’s mesh - a rough approximation is often more efficient and indistinguishable in gameplay. More info
See in Glossary 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 collisionA collision occurs when the physics engine detects that the colliders of two GameObjects make contact or overlap, when at least one has a Rigidbody component and is in motion. More info
See in Glossary event.
Collider events require configuration via C# script; you cannot configure them using only the user interface.
There are two collider event types:
Collider.OnCollisionEnter
, Collider.OnCollisionStay
, and Collider.OnCollisionExit
.Collider.OnTriggerEnter
, Collider.OnTriggerStay
, and 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, OnCollisionEnter2D
). For details of these 2D functions, refer to the MonoBehaviour
API class documentation.