Game Development Reference
In-Depth Information
their
-- target position.
local navPosition = Sandbox.FindClosestPoint(
sandbox, "default", agent:GetPosition());
agent:SetTarget(navPosition);
-- Increase the target radius to prevent agents
from
-- slowing to reach their target position.
agent:SetTargetRadius(1);
end
end
function Sandbox_Update(sandbox, deltaTimeInMillis)
-- Select new paths if agents have reached the end of
their
-- current path.
_UpdatePaths(sandbox);
-- Draw every agent's path.
_DrawPaths();
end
Now that our agents have their own unique paths, we can start seeing how steering, path
following, and avoidance play a part in the movement. As each generated path will be the
shortest possible path, many path segments will overlap when agents move around the
sandbox. Notice that as agents move close to each other, they will deviate off their path in
order to prevent bumping into each other.