Component reference
Physics category
Trigger component
4min
The Trigger component allows you to detect when entities enter or exit a collider's area and perform actions in response.
A Trigger component requires a Collider component (which in turn requires a Rigidbody component) to function.
Property | Description |
---|---|
Target object | The entity that will be affected or receive the action when the trigger is activated. |
OnEnter | The action or event to execute when an entity enters the trigger's collider. |
OnExit | The action or event to execute when an entity exits the trigger's collider. |
- To set up a trigger, add the Trigger component to an entity with a valid Collider.
- Assign a Target object by dragging the desired entity from the hierarchy into the Target object field.
- Select actions for OnEnter and OnExit from the available options, which depend on the target object's components.
- Common actions include Set visible, Set invisible, Play animation, Switch variant, and more.
- The Trigger component is a powerful tool for creating interactive experiences, such as opening doors when a user approaches or changing models in response to player movement.
- Ensure that the collider is properly set up and that the trigger's area covers the space where you want the interaction to occur.