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...
Don't use nav mesh (my terrain is always flat).
Pros: I control how they move.
Cons: They won't avoid trees.
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
Answer by Chrissyeah_ · Sep 03, 2020 at 09:06 PM
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.
Answer by JJJaden · Sep 04, 2020 at 05:31 AM
If you want them to keep distance from each other,
Create a layer
Name the layer zombie
Give the zombie prefab (or zombie gameObjects) the zombie layer
give them all large colliders
open up project setting
go to the physics tab
find the row for zombie
uncheck everything except for zombie (this will make it so only zombies will collide with zombies)
HOPE THIS HELPS
Answer by BenWiller1989 · Sep 04, 2020 at 05:11 PM
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.
Your answer
Follow this Question
Related Questions
how to search for a random point until the condition is true? 0 Answers
Navigatin Mesh agent works for ~10 seconds, then starts moving sporadically 0 Answers
problems with nav mesh agent 0 Answers
How to change enemy AI position through baked walls? 0 Answers
Have players NavMeshAgent ignore Enemy NavMeshObstacle carving 0 Answers