- Home /
Navmeshagents stopping for no reason.
Hey! So I was testing some things with navmeshs and when I had 52 agents at once all calling Agent.SetDestination(PlayerTransform.position) in the update functon, the agents would all stop for a short time and then start up again, happening once every now and then. Obviously it's a bad idea to do that many calls but I was wondering if there is a way to fix this as it has happened with other, smaller amounts of agents making the calls a lot less often (the stopping just happens less often and doesn't last as long).
I've had another project in the past that had 500 agents moving at once with SetDestination() in Update() and it didn't have any problems. I was wondering what the reasoning is. The navmesh I'm using atm is more complex than the one that had 500 agents but not by quite a bit but it's still really simple.
I was mainly wondering if this is a bug, if there is a way to fix it, or does navmesh just have it's limits even if I have a lot more power on my PC to run more agents and what are those limits so I can plan ahead. Any help is appreciated.
Answer by JanusMirith · Oct 14, 2014 at 03:21 AM
The SetDestination() function works over a few frames to spread the load of the calculations.
You could try a few things:
Try setting a queue for the agents and update them in separate frames.
Make the mesh more simple, from the settings or by adding more basic invisible geometry instead of the more complicated visible geometry.
Ahh. Is it possible to keep them walking to their last destination as it appears that they cancel that when the next one starts and that's what causes the stopping I think.
You could place the visuals on a different object with a smoothed follow script or a extrapolation algorithm to give a bit more of a organic feel to the stop and start.
Updating the target at different times per npc will also make things look a bit better, make it look like they are thinking (it is not a bug it is a feature :) )
Answer by Unshackled · Jun 26, 2019 at 04:56 PM
On your NavMeshAgent, uncheck autobraking. This will not allow them to stop when recalculating the path.
I stole this from another post but it worked for me so reposting here.
Answer by Trumped · Jul 27, 2021 at 11:10 AM
I recently had a Problem and fixed it by Moving my Spawn points closer too the navmesh for some reason if you don't spawn them close to the navmesh they will auto correct too it but have strange stuttering when they move.
Your answer
![](https://koobas.hobune.stream/wayback/20220613165039im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
NavMesh Lookat causes jittery glitch in character 0 Answers
Navmesh Path is shown even between disconnected regions.? 0 Answers
Lack of Bi-Direction OffMeshLinks for Jumping Up? 0 Answers
Instantiated objects at beginning of runtime are messing with the pathing for my NavMesh. 0 Answers
Find the nearest location and move to a target outside Navigation Mesh? 1 Answer