So, I have implemented a basic state machine for my character. Now I want to animate the sprite character and I can think of three ways of doing it.
-
I replicate the states and transitions in the animator controller. I assign a bool or trigger condition for the transitions that I change from my fsm state scripts. I.e. The fsm is in move state, the player releases all keys so I change the bool “to_Idle” ( that is a condition of the transition from move to idle states in unity animator ) from my move state script. The animator controller condition “to_Idle” is now true so it transitions to Idle state.
While this works it means that I have to work two times and any change in my fsm states has to be replicated carefully in the Animator controller. -
I replicate only the states in the animator controller and have them all transition from any. This way only my fsm takes care of which states a state con transition to. I tested this with few states and it works but I see that is not how the animator was intended to be used.
-
Using state behaviours. I didn’t try this, but would it be posible to use behaviours scritps to manage the logic of your states ?
How do you do it ?