Is there any way to stop AIs from bunching up while pathfinding?

I’ve made a simple zombie AI using Y3llow Mustang’s tutorial (https://www.youtube.com/watch?v=ibvoqnG3YqI if anyone wants to learn :wink:

i plan on creating hordes/groups of zombies that will converge on a player/players during rounds, there’s one issue however; the AIs will often pick the same targets since the script processes each possible target and picks the closest one, and this causes the AIs to crowd together, which i dont want.

video examples

one player:

multiple players:

as you can see, the bunching can get extreme if all the zombies pick one target, however it starts to lessen as they kill the human and move to other players.

so, are there any ways i can prevent this ai bunching?

You could create a path for 1, get all the waypoints, and place some invisible blocks there to prevent other characters from attempting to go there. and then do that for every NPC. This should stop other npc’s from following the same path as others.

It sounds like you’d be interested in implementing a “boid” algorithm, it’s pretty neat but will have to be modified to suit your needs of course. I’d start here to understand what it is: Boids - Wikipedia

I can’t provide an implementation myself but I did find this video just from googling, perhaps you can start with something like this before building your own solution. https://www.youtube.com/watch?v=Aqss0XUeWfk

I actually did something like this wayyyy back in 2018 but sadly don’t have code w/me but here was my attempt back then https://x.com/realEvanPickett/status/1043983230645366784/video/1

2 Likes

this seems pretty dope, ill be sure to check it out and try this out, thank you!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.