- Home /
How do you combine Animator and fsms
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 ?
Answer by Senuska · Aug 10, 2017 at 01:29 PM
Your first point is the most commonly implemented FSM animator. If you decide to go with this path I would draw out all the states before hand, and keep a document handy to keep track of any changes you have made.
I have not seen the second point done very often, but it may lead to some unexpected behavior.
You can change states in a Monobehavior script (AnimatorStateMachine), but then that just cuts out the Animator entirely.
Answer by theANMATOR2b · Aug 10, 2017 at 08:16 PM
Here are some useful video tutorials using Playmaker
https://www.youtube.com/watch?v=xJSMQutHtIQ&list=PLFXYYxmSM-GecKCLR506o_87B3jmZ_oIz
https://www.youtube.com/watch?v=Ox1RHWh9gRI&list=PLFXYYxmSM-GecKCLR506o_87B3jmZ_oIz∈dex=4
https://www.youtube.com/watch?v=iA0BRFXgLFs&list=PLFXYYxmSM-GecKCLR506o_87B3jmZ_oIz∈dex=3
https://www.youtube.com/watch?v=U0zWHVnpx-w&list=PLFXYYxmSM-GecKCLR506o_87B3jmZ_oIz∈dex=2
https://www.youtube.com/watch?v=49mly6zVAFg&t=5s
Otherwise - idk.