Animation state machine (ASM)
Currently, our animation blending is a bit verbose and requires a lot of manual handling from Lua. Now, we're going to create a system that will manage animations and blends for us based on the concept of a finite state machine (FSM). We'll call this system an animation state machine but in essence, it's an FSM where states are animations and transitions between states represent the blend window, blend duration, and animation offsets.
States
Animation states in Lua will be represented by a table with a few key pieces of information. First, we need to store the animation, state name, whether the state is looping, and at what rate the animation will be played. The ASM will contain one animation state for each animation we support for our soldier.
Note
You can find the book's implementation of an animation state in the src/demo_framework/script/AnimationState.lua
file.
Laying out the AnimationState
class will create an initialization function which assigns default values...