Game Development Reference
In-Depth Information
Playing with blend weights
Now that we have a function that can smoothly blend from one animation to another, we
can modify out playback of the idle animation to the melee animation with our Lin-
earBlendTo function. The key difference that using our LinearBlendTo function has
is that we need to record the time when the blend begins so that it can process the blending
based on our blend duration.
Instead of immediately controlling the melee animation within the Sand-
box_HandleEvent function, we use a Boolean flag to specify whether the soldier
should play the melee animation and handle the blending of the animations within the up-
date function:
Sandbox.lua :
local melee, idle, shouldMelee, meleeStartTime,
meleeStopTime;
function Sandbox_HandleEvent(sandbox, event)
if (event.source == "keyboard" and
event.pressed and event.key == "e_key") then
if (not shouldMelee) then
Animation.Reset(melee);
shouldMelee = true;
meleeStartTime =
Sandbox.GetTimeInSeconds(sandbox);
end
end
end
function Sandbox_Initialize(sandbox)
...
idle = Animation.GetAnimation(soldier, "stand_idle_aim");
Animation.SetEnabled(idle, true);
shouldMelee = false;
melee = Animation.GetAnimation(
Search WWH ::




Custom Search