Support Forum

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

Hi

Which movement script are you using?

AILerp + Seeker + Destination Setter

Hi

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.

Hi

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

var buffer = new List<Vector3>();
oldAI.GetRemainingPath(buffer, out bool stale);
newAI.SetPath(ABPath.FakePath(buffer));