Game Development Reference
In-Depth Information
The idle state
The idle state also supports standing and crouching while slowing down the movement of
the agent at different rates depending on whether the agent is standing or crouching. As the
ASM is fully connected, we don't need to know which state the ASM is currently in and
merely have to request the idle state. This allows the agent to go from a standing run to a
crouch idle animation without the agent knowing specifically what animation transitions
the ASM supports:
DirectSoldierAgent.lua :
function Agent_IdleState(agent, deltaTimeInMillis)
local currentState = _soldierAsm:GetCurrentStateName();
if (_soldierStance == _soldierStances.STAND) then
if (Soldier_IsMoving(agent)) then
-- Slow movement to blend to an idle pose.
Soldier_SlowMovement(agent, deltaTimeInMillis);
end
-- Only request the STAND_IDLE_AIM state if not
currently
-- playing.
if (currentState ~=
Soldier.SoldierStates.STAND_IDLE_AIM) then
_soldierAsm:RequestState(
Soldier.SoldierStates.STAND_IDLE_AIM);
end
else
if (Soldier_IsMoving(agent)) then
-- Slow movement at twice the rate to blend to
an idle
-- pose.
Soldier_SlowMovement(agent, deltaTimeInMillis,
2);
end
Search WWH ::




Custom Search