Guard escorting Inmate on same path

I would like to have a system in my game where a guard would escort an inmate back to its cell. Because of a system of filtering, the guard is the one “driving” the inmate by querying a path to the right destination.

I would like my inmate to follow that same path but a little ahead of the guard, so that my guard appears to be the one following the inmate.

What would be the right way to implement that (currently using GridGraph + AI Lerp, no modifiers)
Is sharing a same path between agent a thing?


Hmm… Ideally I’d try to estimate where the inmate would be say 2 or 3 seconds in the future (call that T), then I’d repeatedly request a path to a point slightly to the side and behind that point. I’d also adjust the speed of the guard so that it would be expected to reach that point in around T seconds (so if the guard is a distance D away from that point, set its speed to D/T).

I can recommend a chapter in AI Game Programming Wisdom 4 called “Company of Heroes Squad Formations Explained”. You might find it interesting.

1 Like

That sounds like a very sound technique, thank you for the idea.