Game Development Reference
In-Depth Information
The moving state
Handling movements takes care of both standing and crouched movements. Standing
movements apply the maximum amount of speed to our agent, while crouched movements
apply one third of our agent's maximum speed. Calculating and applying steering forces
happens exactly the same way as the previous agent movement techniques we've used:
DirectSoldierAgent.lua :
function Agent_MovingState(agent, deltaTimeInMillis)
local currentState = _soldierAsm:GetCurrentStateName();
local deltaTimeInSeconds = deltaTimeInMillis / 1000;
local steeringForces;
if (_soldierStance == _soldierStances.STAND) then
-- Only request the STAND_RUN_FORWARD state if not
-- currently playing.
if (currentState ~=
Soldier.SoldierStates.STAND_RUN_FORWARD) then
-- Change the agent's desired speed for quick
-- movement.
agent:SetMaxSpeed(Soldier.Speed.Stand);
_soldierAsm:RequestState(
Soldier.SoldierStates.STAND_RUN_FORWARD);
end
-- Calculate steering forces tuned for quick
movement.
steeringForces = Soldier_CalculateSteering(
agent, deltaTimeInSeconds);
else
-- Only request the CROUCH_FORWARD state if not
currently
-- playing.
if (currentState ~=
Soldier.SoldierStates.CROUCH_FORWARD) then
-- Change the agent's desired speed for slow
Search WWH ::




Custom Search