Make a new agent reuse the path of an other agent

Hi Aron,

I have an agent which goes properly from point A to point B, following an exact path, I need this agent to spawn a smaller agent at his exact position when he has 50% of his HP (so at any point on the path), and make the smaller agent continue to point B by following the exact same path as the first agent.

Currently the newly spawned smaller agent is not using the same path from the first agent position to point B.

Have a nice day


Which movement script are you using?

AILerp + Seeker + Destination Setter


Sorry for the late reply.
Hmm, not sure why you wouldn’t get the expected result by default, though.

I mean, the remaining path for the large agent is always the shortest path to the destination. So if you spawn a new agent there it should find the same path (or at least a path with an identical length).

Yes the smaller agents always find a path with identical length as the first agent, but often not the same as the first agent.

Is there a way to copy the first agent path and give it to the newer agents ?

Something like SmallAgent.path = BigAgent.path :sweat_smile:

Or even copying all nodes of the BigAgent and give it to the SmallAgent.


If you are using AILerp or AIPath, you should be able to do:

var buffer = new List<Vector3>();
oldAI.GetRemainingPath(buffer, out bool stale);
1 Like

Hey, thanks, it works.

I write what I did for the other astar users :

using Pathfinding;

GameObject invoc = Instantiate(invocationprefab, this.transform.position, Quaternion.identity);
var buffer = new List();
this.gameObject.GetComponent().GetRemainingPath(buffer, out bool stale);

Make sure that the invoc stops searching for path after that, so no path will override the wanted path.
For my project I just disabled “Can Search” in the AILerp script of the invoc.

Have a nice day.