Game Development Reference
In-Depth Information
soldier, "stand_melee_1_with_weapon");
Animation.SetLooping(melee, false);
Animation.SetEnabled(melee, true);
Animation.SetWeight(melee, 0);
Animation.SetTime(melee, Animation.GetLength(melee));
end
function Sandbox_Update(sandbox, deltaTimeInMillis)
Animation.StepAnimation(idle, deltaTimeInMillis);
Animation.StepAnimation(melee, deltaTimeInMillis);
local currentTime = Sandbox.GetTimeInSeconds(sandbox);
if (shouldMelee) then
if ((Animation.GetLength(melee) -
Animation.GetTime(melee)) > 0.5) then
LinearBlendTo(
idle, melee, 0.2, meleeStartTime,
currentTime);
else
meleeStopTime = currentTime;
shouldMelee = false;
end
else
if ((Animation.GetLength(melee) -
Animation.GetTime(melee)) > 0.05) then
LinearBlendTo(
melee, idle, 0.3, meleeStopTime,
currentTime);
end
end
end
Now, every time we press the E key, our soldier will blend into the melee animation and
smoothly blend out into the idle animation.
Search WWH ::




Custom Search