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:
Send an event to all FSMs in the scene that are listening for it.
Send an event to the current FSM, typically to trigger a transition or loop.
Send an event from a template to the host FSM that is running it.
Send an event to a specific FSM Component on the same or different GameObject.
Send a global event to multiple FSM Components.
Send an event to all FSMs on a target GameObject.
Send a global event to FSMs that match a scene hierarchy path pattern.
Send a global event to a specific named FSM on a target GameObject.
Send a global event to all FSMs on a GameObject and its children.
Send an event by name string when you need dynamic event routing.
Queue an event to be sent on the next frame.
Invoke a UnityEvent directly.
Standard Event Flow
When an event occurs:
- Check if the active state handles the event.
- If not handled, check if any global transitions handle the event.
Hierarchical Event Flow
Events are processed in this order:
- Start at the deepest active sub-state.
- Check for a transition or action that handles the event.
- If handled, stop propagation ("consume" the event).
- If not handled, bubble the event up to the parent state.
- Continue until it's either handled or reaches the root.
This is sometimes described as bottom-up propagation.
Why bottom up?
-
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. -
Predictable overrides.
The child can override parent transitions without the parent needing to "know" about it.
-
Matches hierarchical inheritance.
Conceptually, a child inherits parent behavior but can override it - just like in OOP.
-
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.