Experimenting with Unity's animation state machine
We usually see a lot of things going on in Unity's animation state machine graph when we work alongside artists focused on animations, or when we use our own if we have a thing for this discipline; however, it's uncommon seeing things happening in code on top of it. We usually change states via the MonoBehaviour script, and deal with the behaviors in a separate manner.
In this recipe, we will use some of the basic movement behaviors created in Chapter 1, Behaviors – Intelligent Movement, as they are, and we will make our animator control their status.
Getting ready
This recipe doesn't cover the setting up of the animations in the Animator
window. It's up to the reader to set them up. We will focus on the required steps for leveraging the power of the built-in finite-state machine to control our agent.
How to do it...
Let's set everything up first:
- First, create a new
Animator
Controller
using theCreate
button in theProject
window, as shown in...