Getting Started
Getting Started
Samples & Examples
Core Concepts & Glossary
Unity Package Types
Spaces & Space Templates
Custom Avatars
Custom Avatar Animations
Avatar Attachments
Custom Prefab Objects
Components
‣
‣
Quests and Rewards
Drivable Vehicles
Economy
Economy Overview
Monetization
Items
Consumable Items
Rewarding Items
World Currency
Selling Items
Scripting
‣
Guidelines
Supported Features and Limitations
Performance Guidelines
Lighting
Publishing to Spatial
Finding Published Packages
Support
FAQs
Help and Community
Release Notes
Asset Import Settings
Trigger Event
This is an experimental component, It is likely to receive large changes in the future!
Invokes the supplied Events when an avatar enters or exits the trigger respectively. You currently have the choice between Unity Events or Animator events.
Properties
Property | Function |
Listen For | Determines what kind of object will invoke the event when it enters the trigger.
LocalAvatar: The event will only trigger when the local user enter |
On Enter | Event that gets invoked when a valid object enters the trigger |
On Exit | Event that gets invoked when a valid object exits the trigger |
Unity Event Is Synced | When checked all clients will execute the Unity Event when the trigger is activated. This has no affect on the Animator event. |
Collider
In order for a Trigger Event to function it must be placed on a GameObject with a collider that has
Is Trigger
enabled. You can use any shape collider.How To Use 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, then 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.How To Use 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 Events
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 I am setting 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.
Syncing
In order for animator events to be synced across clients the animator being affected must have a Spatial Synced Animator component.
← Previous
Next →