Game Development Reference
In-Depth Information
agent, seekForce, deltaTimeInSeconds);
AgentUtilities_ClampHorizontalSpeed(agent);
local targetRadiusSquared =
(targetRadius + radius) * (targetRadius + radius);
-- Calculate the position where the Agent touches the
ground.
local adjustedPosition =
agent:GetPosition() -
Vector.new(0, agent:GetHeight()/2, 0);
-- If the agent is within the target radius pick a new
-- random position to move to.
if (Vector.DistanceSquared(adjustedPosition,
destination) <
targetRadiusSquared) then
-- New target is within the 100 meter squared
movement
-- space.
local target = agent:GetTarget();
target.x = math.random(-50, 50);
target.z = math.random(-50, 50);
agent:SetTarget(target);
end
-- Draw debug information for target and target radius.
Core.DrawCircle(
destination, targetRadius, Vector.new(1, 0, 0));
Core.DrawLine(position, destination, Vector.new(0, 1,
0));
-- Debug outline representing the space the Agent can
move
-- within.
Core.DrawSquare(Vector.new(), 100, Vector.new(1, 0, 0));
end
Search WWH ::




Custom Search