Trigger Event

Trigger an event when a user enters or exits an area. You can choose to use Unity events or Animator events.

Trigger Event component

Properties

PropertyFunction
Listen ForDetermines what kind of object will invoke the event when it enters the trigger.
On EnterEvent that gets invoked when a valid object enters the trigger
On ExitEvent that gets invoked when a valid object exits the trigger
Unity Event Is SyncedWhen checked all clients will execute the Unity Event when the trigger is activated. This has no affect on the Animator event.

How to Use

Collider

In order for a Trigger Event to work, it must be placed on a GameObject with a collider that has Is Trigger enabled. You can use any shape collider.

Trigger Event Collider

Unity Events

You can add functions to the trigger by pressing the + on the corresponding Unity Event. You can then drag a GameObject into the object field on the left, and choose from any public method available from the dropdown on the right.

In the following video I create a trigger that plays the nearby particle effect when the avatar walks into the cube.

Animator Events

Animator events are a feature specific to the SpatialSDK. They let you modify the parameters of an animator, and with the help of the Synced Animator can be synced across clients.

Adding an event is similar to a Unity Event, but you have to target an Animator.

Once you have targeted an animator, you will be able to choose from any of the parameters on the animator and apply different operations based on the parameter type. In the example below, we set the bool parameter to true when the trigger is entered.

If you are not seeing any option to select a parameter, make sure that you have some defined in your animator.

Adding parameters to animator

Syncing

In order for animator events to be synced across clients, the animator being affected must have a Synced Animator component.

Syncing animator events