The movement should be implemented by character controller, so you need to re declare the OnAnimatorMove method to cover the displacement in the animation clip. Next, it's time to implement FSMDeerMove and FSMDeerDie classes. Protected FSMDeer(FSMManagerBase manager,GameObject deer) : base(manager)ĬharacterController = deer.GetComponent() Protected CharacterController characterController Because animator controls animation and character controller controls movement, you need to declare these two fields, pass them in and assign values in the constructor, and the deer's state machine base class is also completed. In order to be rigorous, first create a deer's state machine base class, which inherits from the state machine base class (see my last article for details, there is a portal at the end). There are three states, which can actually be divided into two: Movement and Die. x indicates the current speed, IsDie indicates whether it is dead, and the animation machine is partially completed.įor the character part, you need to mount the character controller and Animator components, and remember to mount the script components.įirst declare enumeration. What's more, the examples used for practice are not so rigorous. If there are walking animations, you can use x to make a simple hybrid tree. I won't learn the previous tutorial first.
#UNITY SIMPLE STATES HOW TO#
Next time I'll talk about how to do AI patrol. Since the models I use for animation only have three states: Idle, Run and Die, it's relatively simple. This time, first do a simple state machine to control Animator. This time, I will talk about how to use it in practice. The last article talked about the implementation of the general state machine (at the end of the article).