Game Development Reference
In-Depth Information
Running the obstacle course
Actually getting our agent to move requires us to calculate the steering forces based on the
set path and then apply these forces to the agent. Instead of having to set up the same sum-
mation of steering forces we used previously, we can use the Soldi-
er_CalculateSteering function to calculate the appropriate forces and use the
Soldier_ApplySteering function to apply the forces to the agent:
SoldierAgent.lua :
require "DebugUtilities"
function Agent_Update(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());
local deltaTimeInSeconds = deltaTimeInMillis / 1000;
-- Allow the soldier to update any soldier's specific
data.
Soldier_Update(agent, deltaTimeInMillis);
-- Update the animation state machines to process
animation
-- requests.
_soldierAsm:Update(deltaTimeInMillis,
sandboxTimeInMillis);
_weaponAsm:Update(deltaTimeInMillis,
sandboxTimeInMillis);
-- Draw the agent's cyclic path, offset slightly above
the
-- level geometry.
DebugUtilities_DrawPath(
agent:GetPath(), true, Vector.new(0, 0.02, 0));
Search WWH ::




Custom Search