Game Development Reference
In-Depth Information
0));
end
Our following agent is very similar to the pathing agent; it first finds a leader during the
initialization and then uses cohesion and alignment steering forces to try and stay as close
to the leader as possible while using a separation force at the same time to stay at least
two meters away from all other agents, including the leader:
Sandbox.lua
:
function Sandbox_Initialize(sandbox)
...
-- Create a pursuing agent to follow the seeking agent.
Sandbox.CreateAgent(sandbox, "PursuingAgent.lua");
-- Create a group of followers that follow the seeking
agent.
for i=1, 5 do
Sandbox.CreateAgent(sandbox, "FollowerAgent.lua");
end
...
end
Creating five followers and drawing debug circles around them for their separation areas
makes it very easy to see how each force applies to the agent's movements.