S2ENGINE HD 2023
User guide
×
Menu
Index

Events

 
Events are what a FSM needs to change state: when an object is in a state and receives an event it changes state.
How does object know what state to pass to?
The answer is: Transitions.
 
Events are shared among all FSMs of a game scene.
 
There are some default events that are generated by the system, other events can be generated by Animation Keyframes and by Cutscenes, all other events can be generated by Actions.
Default system events are the following:
 
 
To create a new custom event see Events Tab.
 

TRANSITIONS
A transition is a couple (event,state) that associates an event that an object can receive when it is in a given state and the state in which the object must pass if it receives that event.
In other words Transitions define the FSM behaviour, i.e. the new state to pass to in response to an event basing on previous state.
 
What means "basing on previous state"?
Transitions are defined for every state, so previous state means the state that contains the transition while new state means the state transition point to. So when object is in a given state it can pass only to states pointed by transitions contained into that current state, this means that for every state only some events produce a transition to another state. The number and type of transitions for every state is the basic of FSM programming.
 
In the GameMachine graph viewport Transitions are represented as curved oriented lines connecting one event of a state to another state, as showed into the following image:
4.1.3. Events
1

Transition

1. Transition
In this case the transition is connecting the lockEnemy event of state WAIT_FOR_ATTACK to state DEAD01. In other words this means that if the object is inside WAIT_FOR_ATTACK state and receives the lockEnemy event it passes to DEAD01 state.
The color of the transition line is the same as the color of the source state (green in the abpove example).
 

GLOBAL TRANSITIONS
There is a special kind of transition that we call global.
Global transitions are transition that doesn't depend on the current state.
In other words they don't need a previous state to work, this means that global transitions can happen in every state, at any moment, from any source (for example: from other objects FSM, from an animation, from a cutscene, etc...) independently by what the current state is performing.
The only condition they depend on is the event they are associated to occur.
 
A typical example of Global Transition is the transition generated by event START when FSM begins. Thanks to this features Global transitions can help to reduce graph node connections and number of nodes(states) necessary to implement response to an event.
 
In GameMachine global transition are represented as orange comboboxes on top of a state node, as showed into the following image:
4.1.3. Events
1

Global Start transition

1. Global Start transition
This is the global transition triggered by the START event. The FSM starts running from here...

A GameMachine FSM must have at least one global transition to work. The common event to start a FSM is the START event

 
See Edit Transitions in GameMachine graph viewport to know how to create transitions by adding events to a state and connect states.