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.
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).
GameObject invoc = Instantiate(invocationprefab, this.transform.position, Quaternion.identity);
var buffer = new List();
this.gameObject.GetComponent().GetRemainingPath(buffer, out bool stale);
invoc.GetComponent().SetPath(ABPath.FakePath(buffer));
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.