Game Development Reference
In-Depth Information
The move command
The move command handles both crouched- and standing-based movements and changes
the speed of the agent. Once another command is queued, the movement is halted:
SoldierController.lua :
local function _ExecuteMoveCommand(self, agent,
deltaTimeInMillis)
local currentState =
self.asms["soldier"]:GetCurrentStateName();
local deltaTimeInSeconds = deltaTimeInMillis / 1000;
local steeringForces = nil
if (_stance == SoldierController.Stances.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);
self.asms["soldier"]:RequestState(
Soldier.SoldierStates.STAND_RUN_FORWARD);
elseif (#self.commands > 0) then
-- Continue executing till a new command is
queued.
_ClearExecutingCommand(self);
end
-- Calculate steering forces tuned for quick
movement.
steeringForces =
Soldier_CalculateSteering(agent,
deltaTimeInSeconds);
else
-- Only request the CROUCH_FORWARD state if not
currently
Search WWH ::




Custom Search