Triggers

Triggers enable the automation of server side actions at a set moment in time or as the result of another server event from Unity Gaming Services (UGS).

They enable Cloud Code scripts and modules to be run automatically, without the need for a client to make a request to the server.

Events

An event defines a change in state that has occurred in the server. Events can be emitted by internal Unity Gaming Services, such as the Authentication service, or by the Scheduler service.

For example, every time a player signs in, the Authentication service emits an event.

Refer to Events and Supported UGS events for more information.

Scheduler

Use the Scheduler service to emit events at a set or recurring moment in time.

For example, a scheduler enables you to do the following:

  • Send an announcement to all users wishing them a happy new year at 00:00:00 UTC on January 1st.
  • Change a game theme at 00:00:00 UTC on the first day of every month.
  • Reward top players at the end of every month.

Triggers

The Triggers service monitors a stream of internal events, emitted by Unity Gaming Services and the Scheduler service. Triggers allow users to define rules to automatically perform a chosen action (for example, run a Cloud Code script) when UGS emits a particular event.

A trigger can enable use cases such as:

Use caseEvent emitted byTriggered byAction
Initialize player data in Cloud Save every time a new player signs upAuthenticationSigned up eventRun a Cloud Code module or script.
Sends a push message to all users wishing them a happy new yearSchedulerScheduled eventRun a Cloud Code module.
Reward top players with in-game currency at the end of seasonLeaderboardsReset eventRun a Cloud Code module or script.
Send a push message to the player whose score was beatenLeaderboardsScore submitted eventRun a Cloud Code module.
Announce a level up to all players in joined lobbiesCloud SaveKey saved eventRun a Cloud Code module.
Moderate player actionsModerationModeration eventRun a Cloud Code moderation script.

Filters

Filters are optional conditions that you can add to a trigger to define when the trigger fires. For example, you can define a filter to only fire a trigger for a Leaderboard event when a player submits a score of 100 or more.

Refer to Filters for more information.

Note: Currently, you can only create triggers with filters through the Triggers API.

Next steps

Take a look at the following guides to learn more about Triggers:

GuideDescription
EventsLearn about how events work, how they are emitted and their structure.
Trigger structureLearn about the structure of a trigger and how you can associate it with an event.
Supported UGS eventsLearn about the different types of events that can be emitted by UGS.
Schedule events using the CLI or API.Learn how to create scheduled events.
Define triggers using the CLI or APILearn how to define triggers to run Cloud Code scripts or modules when an event is emitted.
Access controlLearn about the access control model for Triggers.