Game Development Reference
In-Depth Information
The move action
Our movement action is similar to an idle action, as the agent's walk animation will loop
infinitely. In order for the agent to complete a move action, though, the agent must reach
within a certain distance of its target position or timeout. In this case, we can use 1.5
meters, as that's close enough to the target position to terminate the move action and half a
second to indicate how long the move action can run for:
SoldierActions.lua :
function SoldierActions_MoveToCleanUp(userData)
userData.moveEndTime = nil;
end
function SoldierActions_MoveToInitialize(userData)
userData.controller:QueueCommand(
userData.agent,
SoldierController.Commands.MOVE);
-- Since movement is a looping animation, cut off the
move
-- Action after 0.5 seconds.
local sandboxTimeInMillis =
Sandbox.GetTimeInMillis(userData.agent:GetSandbox());
userData.moveEndTime = sandboxTimeInMillis + 500;
return Action.Status.RUNNING;
end
When applying the move action onto our agents, the indirect soldier controller will manage
all animation playback and steer our agent along their path.
Search WWH ::




Custom Search