One agent lagging way behind on terrain

thretch

Member
I have a situation where 4 agents follow a leader, but all use the same exact prefab (thus, instances), this the exact same Behavior. The only difference is when the followers are spawned, a "isLeader" bool is set to false, whereas the leader is set to true. Works great, UNTIL I put them on a terrain. (was on a test plain before). Now, ONE of the followers (seeming randomly) always lags very far behind the others. Like 3-4X as far away from the leader as the rest.

Can you think why this might be happening, when every follower is a instance of the exact same Prefab?
 
This sounds like it is locomotion related. If you select the agent that is lagging you'll see their NavMeshAgent destination and I bet that it will be in the correct position, it's just that the locomotion for that agent is having a hard time keeping up.
 
It's tough to see from that screenshot, but is the target NavMeshAgent position correct? You may have to have the navmesh editor open in order to see it. What are you using for locomotion?

Is it possible to accidentally develop a race condition between the Leader Follow code and the Agent's?
I do not think so but anything is possible. :) If the target position is correct then the tasks are working correctly though.
 
Latest on this- when I look at the details of the agent, it appears as though its cycling through seeking and not seeking, with these red squares appearing and disappearing every second or so...

1571135245889.png
 
It just HAS to be something in the Seek behavior. The leader that they are all following uses the Patrol behavior and he has NO issues whatever! Grr.. :/
 
That image helps a lot. You're using a formation task, correct? Within FormationGroup there is this comment to the code:

// If the destination is immediately in front of the agent then that agents stopping distance will take over and slow down the agent. This will make the agent
// lag behind the leader. Prevent this from happening by adding a small look ahead distance.

It looks like the agent is getting too close to the destination so the stopping distance is starting to stop the character. You can try decreasing the stopping distance on the navmeshagent, or increasing the look ahead distance on the formation task.
 
I've been using the Seek behavior. Also tried Follow and Move Towards. My stopping distance is set to 0. I don't see the Look Ahead value...
 
Seek uses the same base class as patrol and has more straight forward logic so it's odd that you are getting this behavior with seek. Move Towards doesn't use the navmesh so you don't want to use that.

Seek has an arrived distance parameter - have you tried reducing that?
 
Yes. Gradually set it all the way down to 0. I think something is wrong with my terrain. It's been sectorized (SECTR). Do you think that may have anything to do with it?
 
I haven't used SECTR so I'm not sure. Does it work correctly on a standard terrain?
 
Top