Download

AI character to walk next to you dynamically?

Hey there, folks! I’ve currently got an AI character to home in on my character’s location and go there at the push of a button. So far, looking great! However, I’d like to get it to the point where the AI character will walk next to the player, following alongside them wherever they go. How would you recommend I go about doing this?

Just to clarify, I’d like to have the AI stay on the player’s left, or right side. When the player turns, the AI will turn with him, remaining at the player’s side.

f5f684d5f84b1a06cb160201c3e70ffef5f89901.png

Any hints would be fantastic! Thanks in advance!

I no absolutely nothing about AI, but whats to stop you from just setting the AI walk location to # units right of player every frame?

Thanks for the response! I’ll consider that, but I’ll wait to see what someone with some AI experience has to say as well before I try scripting blindly! :slight_smile:

Alright :stuck_out_tongue:

What I would do is:
Spawn a target point and attach it to the player character then add a local offset to it.
Then just tell the AI to move to that actor.

Oooooh! Now there’s an idea! I’ll see what I can do.

Maybe you could make a Blueprint with Target points only. You attach this “formation” to your player blueprint.
then each AI chooses one of the target points and tries to walk towards it.
the formation rotates with the player, so this should achieve your desired behaviour. haven’t tested it though. if it works, let us know :slight_smile:

if it works, you could make several different formations: diamond, V formation, echelon, etc… and let the player choose one

If you place a point near your player, the whole thing would be limited to this point.

You need to find a “random” point around your player in a maximum distance away from him. So as long as you don’t move away from that
point, the AI will stay and if you are too far away, you just search for a new point (there is an actual node for that using the nav mesh) and
let the AI move to it.

Disappointed af that nobody has posted a solution to this. I cannot find a single resource explaining how to make this work.