Game Development Reference
In-Depth Information
Updating running animations
After checking whether the ASM is transitioning, we now need to handle stepping anima-
tions. Two cases can exist in the ASM: either we are stepping multiple animations when
handling a transition, or we are stepping the current state's animation only. When stepping
multiple animations during a transition, it's necessary to clear out a finished animation
based on the animation's weight, and then set the ASM to the next state:
Sandbox.lua :
function AnimationStateMachine.Update(
self, deltaTimeInMillis, currentTimeInMillis)
...
if (self.currentTransition_) then
AnimationUtilities_LinearBlendTo(
self.currentState_.animation_,
self.nextState_.animation_,
self.currentTransition_.duration_,
self.transitionStartTime_,
currentTimeInSeconds);
StepAnimation(
self.currentState_.animation_,
deltaTimeInMillis,
self.currentState_.rate_);
StepAnimation(
self.nextState_.animation_,
deltaTimeInMillis,
self.currentState_.rate_);
if (Animation.GetWeight(
self.currentState_.animation_) == 0) then
ClearAnimation(self.currentState_.animation_);
self.currentState_ = self.nextState_;
self.nextState_ = nil;
Search WWH ::




Custom Search