Component reference
Physics category

Trigger component

4min

Description

The Trigger component allows you to detect when entities enter or exit a collider's area and perform actions in response.

Requirements

A Trigger component requires a Collider component (which in turn requires a Rigidbody component) to function.

Properties

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.

Usage notes

  • 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.

Important details

  • 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.



Updated 14 Nov 2024
Doc contributor
Did this page help you?