Skip to content

Broadcast Event

Broadcast a Global Event to all FSMs.

Parameters

Parameter Description
Event The global event to broadcast to all subscribers.
Data Optional data to send with the event.
Delay Optional delay in seconds before broadcasting the event.

Details

For optimal performance, broadcast only sends the event to FSMs that are currently subscribed to the event. This is managed automatically.

A state that broadcasts an event shows a broadcast icon:

Broadcast Icon

Click on the icon to navigate to places where the event is used.

Debugging

While playing you can see current subscribers in the Global Event Inspector.

Examples

Global Events are a good way to decouple systems.

A player can simply broadcast Player Died when hit by an enemy, and any systems interested in that event can respond. For example, a Lives Counter FSM could check if the player has any more lives left and broadcast either a Game Over or Next Life event. The Game Manager FSM can listen for these events and respond appropriately. And so on...

This approach has many advantages:

  • Systems are decoupled.
  • Key game events are clearly defined.
  • You can quickly find FSMs that use these events.
  • The game loop is self documenting with these events.

Overall this approach makes the game loop easier to understand and maintain.