I wrote an example for the demo:
The demo state machine is controlled by the value of variable i
, the value of variable j
and the buttons
.
The conditions determine which state the state machine enters.
Start state

A to B state by AtoB button

B to C state by j > 100 and BtoC button

A to B Transitionitem


The image above shows the TransitionItem controlling from state A to state B.
From State: A_State
(A_State.tres)
To State: B_State
(B_State.tres)
Actions: SetBLamp
(SetBLamp.tres) 'action for B_State'
A class (SetStateLampRES.cs) includes SetBlamp.tres describes what to do when:
- if it enter the state:
OnStateEnter()
-> demoStateMachine.bLamp = true;
- if it exit the state:
OnStateExit()
-> demoStateMachine.bLamp = false;
- if it is in the state:
OnUpdate()
-> in this case it does nothing
The transition condition is as follows: i > 10 && j < 20 || A->B button
If the logical result of the elements of the ConditionUsage array is true, then the transition occurs.
A->B button &&
ConditionUsage will be true if:
- Expected Result:
True
-> the result of the Condition is true,
- Condition:
AtoBbuttonCondition
(AtoBbuttonCondition.tres) is fulfilled. The class (ButtonStatusConditionRES.cs) includes AtoBbuttonCondition.tres describes how the result of the condition is formed: bool state = demoStateMachine.AtoBbutton;
,
- Operator:
And
-> logical connection with the following ConditionUsage.
(In this case it doesn't matter since there is no next element)