Indirect animation control
Now that we've implemented direct ASM control from the agent's point of view, we're going to create a system that manages the ASM while taking commands from the agent. One layer of abstraction above the ASM helps separate decision-making logic that resides in the agent and low-level animation handling.
Take falling, for example—does it make sense for the agent to constantly care about knowing that the agent is falling, or would it make things simpler if another system forces the agent to play a falling animation until the agent can interact with the environment again?
The system we'll be creating is called an animation controller. As animation controllers are very specific to the type of agent we create, you'll tend to create a new animation controller for each and every agent type.
The animation controller
Creating an animation controller will follow an object-oriented style that is similar to the ASM. First, we create a new function that creates variables for holding...