Game Development Reference
In-Depth Information
Creating animation state machines
The animation state machine is created in a way that is very similar to transitions and
states. We create a new Lua table and assign some basic attributes to the table. In this case,
we'll need to know about the current state that is being played, whether there is a current
transition happening, the next state the ASM is trying to transition to, the start time of the
transition, as well as tables that represent the states and transitions of the ASM.
Note
You can find the topic's implementation of an animation state in the src/
demo_framework/script/AnimationStateMachine.lua file.
When we create an AnimationStateMachine instance we'll also assign default val-
ues, as well as create internal tables for store states and transitions.
Sandbox.lua :
require "AnimationUtilities";
AnimationStateMachine = {};
function AnimationStateMachine.new()
local asm = {};
-- data members
asm.currentState_ = nil;
asm.currentTransition_ = nil;
asm.nextState_ = nil;
asm.states_ = {};
asm.transitions_ = {};
asm.transitionStartTime_ = nil;
return asm;
end
Search WWH ::




Custom Search