Hi, I am currently working on a state system for my 2D sprite player character and it appears to be more complicated than I initially thought.
Now I wonder if it makes sense to introduce two state machines. One for animations and one for the actual movement.
I have the following animations:
Default Walk
Stair Walk
Carry Walk (Walk when the player is carrying an object)
Default Idle
Carry Idle
Lift object
Throw object
Attack
Hurt
Die
Some animations can exist in different move states. Currently, I have three kinds of movements:
Halt (the character does nothing but wait for user input, don't know if this is a correct English term)
Move (the character moves according to the user input / arrow keys)
Automatic (the character ignores user input and the game controls its movement, for instance the character goes down a stair automatically)
Let's take a look at Default Walk and Carry Walk for instance.
There can be a situation where the Default Walk / Carry Walk animation is playing and the character is controlled
by user input but it is also a possible state that those animations are playing and the movement is controlled by the game
(automatic).
That means a certain animation can play during different movements.
Therefore I thought I could have an AnimationStateMachine that switches between the Animations and a MoveStateMachine that switches between Halt, Move, and Automatic.
If I use one State machine I have states like AutomaticCarryWalk or AutomaticDefaultWalk.
Or does it have any flaws because I couldn't find a source where this approach was chosen.?
Thanks Bernd