Trigger events are Unity's way of telling you when an object enters, stays inside, or exits a trigger zone. The objects pass right through each other with no bouncing, no stopping, no physics reaction.
Requires Collider marked as Is Trigger Objects don't physically block each other Perfect for pickups, zones and area detection 👁 Trigger-Events-In-Unity Trigger Events In Unity Trigger Event Methods Unity provides three trigger events that you can use in your scripts. Example:
OnTriggerEnter : Most commonly used (collecting, activating, damaging) OnTriggerStay : Use for continuous effects (poison zone, healing area) OnTriggerExit: Use for leaving detection (exit message, disable effect) Collider Parameter It gives you access to the object that entered. Example :
other.gameObject : The GameObject that entered the trigger other.tag / other.CompareTag() : Check what type of object other.GetComponent<T>() : Access components on the entering object Setting Up a Trigger To create a trigger zone:
Create a GameObject (Cube, Sphere, or empty) Add a Collider component Check the Is Trigger checkbox in Inspector Adjust size and position of the collider (Optional) Disable Mesh Renderer to make it invisible 👁 Box-Collider-In-Unity Trigger is check In Box Collider Requirements for Trigger Events For OnTriggerEnter/Stay/Exit to work:
At least one object must have a Collider marked as Is Trigger The entering object needs a Collider (can be any type) Rigidbody is optional (unlike collision events) This makes triggers more flexible than collisions:
Trigger can detect objects with or without Rigidbody Trigger itself doesn't need Rigidbody at all Practical Examples Example 1 : Coin Collection
Example 2 : Checkpoint Activation
Example 3 : Door that opens when player approaches