Getting our soldier to run
Now that we have an animated agent, we can get the agent to run around the obstacle course while animating with the same steering techniques we used previously. First, we set the agent's path, which is provided by the SandboxUtilities_GetLevelPath
function, and then we request the ASM to let the agent play the run_forward
animation.
Setting a path through the obstacle course
You can set a path through the obstacle course as follows:
SoldierAgent.lua
:
require "SandboxUtilities" function Agent_Initialize(agent) ... _soldierAsm:RequestState( Soldier.SoldierStates.STAND_RUN_FORWARD); -- Assign the default level path and adjust the agent's speed -- to match the soldier's steering scalars. agent:SetPath(SandboxUtilities_GetLevelPath()); agent:SetMaxSpeed(agent:GetMaxSpeed() * 0.5); end
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...