Book Image

Learning Game AI Programming with Lua

By : David Young
Book Image

Learning Game AI Programming with Lua

By: David Young

Overview of this book

Table of Contents (16 chapters)
Learning Game AI Programming with Lua
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Free Chapter
1
Getting Started with AI Sandbox
Index

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...