Skip to content

Event

These actions send events to trigger transitions and coordinate behavior across FSMs.

Use them to:

  • Trigger transitions in the current FSM.
  • Send events to other FSMs or GameObjects.
  • Broadcast events globally to all FSMs listening.

Event Targets

There are a variety of ways to send events:

Broadcast Event

Send an event to all FSMs in the scene that are listening for it.

Send Event

Send an event to the current FSM, typically to trigger a transition or loop.

Send Event To Host

Send an event from a template to the host FSM that is running it.

Send Event To FSM Component

Send an event to a specific FSM Component on the same or different GameObject.

Send Event To FSM Components

Send a global event to multiple FSM Components.

Send Event To GameObject

Send an event to all FSMs on a target GameObject.

Send Event To Scene Path

Send a global event to FSMs that match a scene hierarchy path pattern.

Send Event To GameObject FSM

Send a global event to a specific named FSM on a target GameObject.

Send Event To Children

Send a global event to all FSMs on a GameObject and its children.

Send Event By Name

Send an event by name string when you need dynamic event routing.

Send Event (Next Frame)

Queue an event to be sent on the next frame.

Invoke Unity Event

Invoke a UnityEvent directly.

Standard Event Flow

When an event occurs:

  1. Check if the active state handles the event.
  2. If not handled, check if any global transitions handle the event.

Hierarchical Event Flow

Events are processed in this order:

  1. Start at the deepest active sub-state.
  2. Check for a transition or action that handles the event.
  3. If handled, stop propagation ("consume" the event).
  4. If not handled, bubble the event up to the parent state.
  5. Continue until it's either handled or reaches the root.

This is sometimes described as bottom-up propagation.

Why bottom up?
  1. Local specificity wins.

    The whole point of nesting is specialization: sub-states are refinements of parent behavior.
    You want a "Run" state to override how "Move" handles STOP.

  2. Predictable overrides.

    The child can override parent transitions without the parent needing to "know" about it.

  3. Matches hierarchical inheritance.

    Conceptually, a child inherits parent behavior but can override it - just like in OOP.

  4. Mirrors UI and scripting event bubbling.

    The same pattern is used in GUI frameworks (e.g. Unity's UI Toolkit, WPF, web DOM): the event is offered to the deepest element first, then bubbles up if not consumed.

Debugging

Use the FSM Log to view and debug all events sent during Play Mode.

The log helps you verify:

  • Which events were sent and when.
  • Which FSMs received and responded to those events.
  • Whether transitions occurred as expected.