Game Development Reference
In-Depth Information
The random move action
Randomly moving is an action that chooses a random point on the navmesh to be moved
to. This action is very similar to other actions that move, except that this action doesn't per-
form the moving itself. Instead, the random move action only chooses a valid point to
move to and requires the move action to perform the movement:
SoldierActions.lua :
function SoldierActions_RandomMoveCleanUp(userData)
end
function SoldierActions_RandomMoveInitialize(userData)
local sandbox = userData.agent:GetSandbox();
local endPoint = Sandbox.RandomPoint(sandbox, "default");
local path = Sandbox.FindPath(
sandbox,
"default",
userData.agent:GetPosition(),
endPoint);
while #path == 0 do
endPoint = Sandbox.RandomPoint(sandbox, "default");
path = Sandbox.FindPath(
sandbox,
"default",
userData.agent:GetPosition(),
endPoint);
end
userData.agent:SetPath(path);
userData.agent:SetTarget(endPoint);
userData.movePosition = endPoint;
return Action.Status.TERMINATED;
end
Search WWH ::




Custom Search