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

Building a weapon animation state machine


Now that we've built an entire animation state machine system, it's time to build the ASMs our soldier will use. As the soldier's weapon is the simplest ASM, we'll start there first. With only five different animations, this is a relatively easy ASM to build.

First, we add each of the states with their corresponding animations and specify whether the animation is looping or non-looping. Next, we connect each state via transitions. Lastly, we request a state within the ASM to start playing a looping animation; in this case, this is the sniper_idle state.

The sniper/submachine gun animation state machine

Note

The reload animation for the weapon only works when the weapon is in its sniper pose. The ASM must reflect this; otherwise, you will see a noticeable pop on the sniper pose before the reload animation plays.

Creating the weapon ASM primarily consists of adding each state, the states corresponding to the animation to play, and creating transitions between...