Zombie Horde All Walking in Line! I Need them to spread out.

Right now I spawn around 100-200 zombies a good distance from the player. The spawning works fine but they are using nav mesh agent and I SetDestination(player.position) They form into two lines and follow.

I can think of a few things to do…

  1. Don’t use nav mesh (my terrain is always flat).

Pros: I control how they move.

Cons: They won’t avoid trees.

  1. Do something like this with nav mesh and choose a random curve

Pros: They all seem kind of random and semi-intelligent.

Cons: I would have no idea how to achieve this with nav mesh agent :).

Any Ideas or thought appreciated! Thanks


This one is quite difficult. One approach could be randomising their destination a bit. You could plot out a path yourself. Another solution could be to try the A* pathfinding system, using this system you can assign weights to the path’s your zombies will take, which will break up their pathfinding a bit, and get them to take alternate routes.

It’s quite a useful pathfinding solution, I have used it to dynamically update the pathfinding data with my building game so newly built walls will be avoided in pathfinding.

If you want them to keep distance from each other,

  1. Create a layer
  2. Name the layer zombie
  3. Give the zombie prefab (or zombie gameObjects) the zombie layer
  4. give them all large colliders
  5. open up project setting
  6. go to the physics tab
  7. find the row for zombie
  8. uncheck everything except for zombie (this will make it so only zombies will collide with zombies)


Since it’s a mass production of zombies, here is how I would go about it : 1 : you have a fixed amount of zombies that should spread out randomly or controlled, whatever fit your needs. You have a fixed or maybe overall average start distance to the player. 2 : For each zombie, create an updated Vector3 destination in line to the other destinations. Those destinations should move stepwise toward the player. 3 : Now as the average distance of the zombos to the player gets smaller, so does the average distance from the destinations, but the space between the destinations in line get bigger. You have to interpolate the space in between and the distance of the destinations by the half length of the average start distance, in order to reverse the space after passing the half length later on. 4 : Now, the less zombos there are, the smaller is the line of the destinations. When you have the lines, you can play around with the values of some axis to make it more random. Sounds like a lot of work, but it’s actually pretty simple and short in edition.

Thanks for all your replies I’ll try them out!