Course contentsShow
← Unity Game Development
Lesson 411 of 8286. Animation and CinemachineFree lesson

Triggering Game Events Using Signal Emitters

Implement Signal Emitters to broadcast specific events from the Timeline to your game scripts at precise moments.

In this lesson, you will learn how to bridge the gap between your cinematic Timeline sequences and your active gameplay logic using Signal Emitters.

The Role of Signals in Timeline

While you’ve used the Timeline to animate objects and control Cinemachine cameras, you often need to trigger gameplay-specific code—like spawning an enemy, playing a sound effect, or enabling a UI element—at a specific frame. Instead of hardcoding these triggers, we use Signals.

A Signal system consists of three parts:

  1. Signal Asset: An empty data file that acts as a unique ID for your event.
  2. Signal Emitter: A clip placed on a "Signal Track" within your Timeline that fires the Signal Asset at a precise moment.
  3. Signal Receiver: A component on a GameObject that listens for the Signal Asset and executes a corresponding method.

Implementation Workflow

First, create a new Signal Asset in your Project window (Right-click > Create > Timeline > Signal). Next, add a "Signal Track" to your Timeline. Right-click the track to add a Signal Emitter and assign your Signal Asset to it.

Finally, attach a Signal Receiver component to the object you want to control. In the receiver’s inspector, link your Signal Asset to a function in your script, similar to how you would hook up a button’s OnClick() event:

public class GameplayTrigger : MonoBehaviour 
{
    public void OnCutsceneEvent() 
    {
        Debug.Log("Signal received! Spawning enemies now...");
        // Add your logic here
    }
}

By decoupling the timing of the event (Timeline) from the execution of the code (the Receiver), you create modular, maintainable cutscenes. You can drag and drop your GameplayTrigger component into the Signal Receiver’s list, select OnCutsceneEvent, and your event will fire perfectly in sync with your visual narrative.

This approach ensures that your game logic remains clean and your animations stay perfectly timed without needing to manually poll for frame numbers in your scripts.

Key Takeaway: Signal Emitters allow you to broadcast custom events from your Timeline, enabling you to trigger complex game logic at precise moments without tight coupling between your cinematic sequences and gameplay scripts.