Game Development Reference
In-Depth Information
The falling state
As the soldier's ASM doesn't have a falling animation directly, two different animation
states are used to simulate a falling death. When an agent begins to fall, we play the stand-
ing idle animation and immediately play the fall_dead animation once the agent is no
longer falling. The same physics removal takes place when the agent gets killed or dies
from a fall:
DirectSoldierAgent.lua :
function Agent_FallingState(agent, deltaTimeInMillis)
local currentState = _soldierAsm:GetCurrentStateName();
-- Since there's no falling animation, move the soldier
into
-- an idle animation.
if (currentState ~= Soldier.SoldierStates.STAND_IDLE_AIM
and
currentState ~=
Soldier.SoldierStates.STAND_FALL_DEAD)
then
_soldierAsm:RequestState(
Soldier.SoldierStates.STAND_IDLE_AIM);
end
-- Once the soldier is no longer falling, kill the
soldier.
if (not Soldier_IsFalling(agent)) then
if (currentState ~=
Soldier.SoldierStates.STAND_FALL_DEAD) then
-- Play a death animation once the soldier stops
-- falling.
_soldierAsm:RequestState(
Soldier.SoldierStates.STAND_FALL_DEAD);
elseif (currentState ==
Soldier.SoldierStates.STAND_FALL_DEAD) then
Search WWH ::




Custom Search