The value of the states does not matter, as long as they are unique. Your stand state could be represented by a value 0, 99, or 12994. What makes the state method work is that in each input that would change the actor's state, you use a switch statement so you can outline the exact transition code you want. So in your crouch keydown event, you need to decide which states transition to what.
player -> Key Down down (repeat enabled)
- stand right transitions to crouch right
- stand left transitions to crouch left
You also need to define ways to transition out of the new states, otherwise no input event would be able to escape the new state and your actor will freeze.
player -> Key Up down
- crouch right transitions to stand right
- crouch left transitions to stand left
In general a transition only requires two lines of code. One to change the value of state to the corresponding state, and two to change the animation to the proper state. Here's the script for the key down event.
- Code: Select all
switch(state)
{
case 0: // stand right
ChangeAnimation("Event Actor", "crouch_right", FORWARD);
state = 4; // assuming crouch right is represented by 4
break;
case 1: // case for stand left transitioning to crouch left
ChangeAnimation("Event Actor", "crouch_left", FORWARD);
state = 5;
break;
}
To sum it up, to add a new state you need to pick a value for that state, and provide transition code to and from it. Transitions require minimally the change of the state value, but usually also include a ChangeAnimation call.