Game Development Reference
In-Depth Information
Playing an animation on our soldier
Playing an animation on our soldier requires three important parts. First, we need to acquire
the animation based on its name; then, we need to enable the animation; and then, we need
to update the animation during our normal sandbox update loop.
Note
It is the sandbox's responsibility to step the animation based on the delta time the sandbox
updates with.
Obtaining an animation is performed by the Animation.GetAnimation function,
while enabling an animation is done through the Animation.SetEnabled function,
and lastly stepping our animation is done with the Animation.StepAnimation func-
tion.
Sandbox.lua :
local idleAnimation;
function Sandbox_Initialize(sandbox)
...
idleAnimation = Animation.GetAnimation(
soldier, "stand_run_forward_weapon");
-- Allow the animation to affect the soldier's skeleton.
Animation.SetEnabled(idleAnimation, true);
end
function Sandbox_Update(sandbox, deltaTimeInMillis)
Animation.StepAnimation(idleAnimation,
deltaTimeInMillis);
end
Search WWH ::




Custom Search