Game Development Reference
In-Depth Information
The death state
The first action we'll implement is the death state of the agent. As the ASM provides both a
crouch and standing death variation, the action simply slows the agent's movement and re-
quests the ASM to play the death animation. Once the agent begins to animate, the agent's
physics representation is removed from the sandbox and the agent's health is set to zero, so
no additional actions will be processed once death has occurred:
DirectSoldierAgent.lua :
function Agent_DeathState(agent, deltaTimeInMillis)
local currentState = _soldierAsm:GetCurrentStateName();
if (Soldier_IsMoving(agent)) then
-- Slow movement at twice the rate to blend to a
death
-- pose.
Soldier_SlowMovement(agent, deltaTimeInMillis, 2);
end
-- Only request a death state if not currently playing.
if (_soldierStance == _soldierStances.STAND) then
if (currentState ~=
Soldier.SoldierStates.STAND_DEAD) then
_soldierAsm:RequestState(
Soldier.SoldierStates.STAND_DEAD);
end
else
if (currentState ~=
Soldier.SoldierStates.CROUCH_DEAD) then
_soldierAsm:RequestState(
Soldier.SoldierStates.CROUCH_DEAD);
end
end
-- Remove the soldier from physics once the death
animation
Search WWH ::




Custom Search