Most efficient way for agents to follow other agents?

110 views
Skip to first unread message

Arne De Jonghe

unread,
Jan 29, 2021, 11:05:36 AM1/29/21
to recastnavigation
Hi,

With dtCrowd I am trying to make agents follow other agents.

What I'm currently doing is find the target agent's dtPolyRef with findNearestPoly and then set the target of the crowd agent. The problem with this method is that using findNearestPoly seems to be pretty expensive, especially considering that a large amount of agents need to follow their own target each in my game.

Is there a built-in way with dtCrowd where an agent can follow another agent?
Or is there a way to retrieve what dtPolyRef an agent is in without having to do unnecessary calculations?

Thanks in advance.

Arne De Jonghe

unread,
Feb 24, 2021, 5:22:06 AM2/24/21
to recastnavigation
I figured it out I think. To get an agent's current PolyRef do:

const dtPathCorridor *corridor = &agent->corridor;
dtPolyRef ref = corridor->getFirstPoly();

Correct me if I'm wrong though.
 

Reply all
Reply to author
Forward
0 new messages