Game Development Reference
In-Depth Information
Updating the controller
Updating the controller itself is responsible for updating the associated ASMs as well as
handling internal checks for agent changes such as dying and falling. Advancing the ex-
ecuting command also happens during updates when a command is queued and no com-
mand is currently executing. If a command is currently executing, the associated callbacks
are invoked:
SoldierController.lua :
function SoldierController.Update(
self, agent, deltaTimeInMillis)
-- Returns the amount of time that has passed in the
sandbox,
-- this is not the same as lua's os.time();
local sandboxTimeInMillis =
Sandbox.GetTimeInMillis(agent:GetSandbox());
-- Allow the soldier to update any soldier's specific
data.
Soldier_Update(agent, deltaTimeInMillis);
-- Update the animation state machines to process
animation
-- requests.
_UpdateAsms(self, deltaTimeInMillis,
sandboxTimeInMillis);
-- Ignore all state requests once the agent is dead.
if (agent:GetHealth() <= 0) then
return;
end
-- Force the soldier into falling, this overrides all
other
-- requests.
if (Soldier_IsFalling(agent)) then
Search WWH ::




Custom Search