Path searching every frame for lots of Ai’s can be quite heavy. I suggest you use coroutines and use yield WaitForSeconds(). You don’t really have to path search every frame. I’m no expert but I usually do it every 0.2 - 0.3 seconds and it works just as good. If you have lots of them I suggest creating a manager that handles batch searching to keep the count down.
You could make it so the path search rate is increased the closer you get to the player/move-target, basically what aegget_ said but with a bit more dynamic…ness to it. You could also do NavMesh.CalculatePath, store that and move your zombies along that path as a rigidbody or character controller. The problem I’ve found though is that even if you set 100+ NavMeshAgents to move to a certain point at the same time only once, it will still lag. So the problem is with the NavMeshAgent updating itself too often.
As i realised the nav mesh just was not going to work for me, I switched to an A* path finding script using a grid and now I can have up to 70 zombies with 45 FPS which is fine. But I was able to increase the count of AI by putting the re-path to half a second rather then each frame.
Im using Aron Granbergs A* Project, it works well, but when i have over 50 zombies they have a slight delay on finding a path to me, which is reasonable
My ideal solution to this problem would be to use a point to point Graph, as it can calculate a path so much faster, however when i tried it the zombies were walking into walls to get to me at times.
As you have an A* path finding solution i have a question, how do you set up a point Graph
I put the points on every corner for the zombies, is that correct?
and if this delay begins to annoy me and I cant figure out the points graph on Aron’s then maybe ill give your’s a try