Using the new navmesh in Unity (5.6.0) we’re getting a bug where agents are getting caught on the corners of nav mesh cells. They end up moving back and forth on the spot and not progressing towards their target.
Have you tried to play around with Acceleration and Speed of the NavMesh agent? I had similar problems, but I fixed it with setting these values:
Speed = Value;
Acceleration = Value * 1,25;
If you increase timescale it still might happen sometimes, also set autoBreaking = true and autoRepath = true.
I have also written some code for my formations to prevent getting stuck in those loops. Please note that the code does not use the NavMesh class. If you have problems understanding the code let me know, and I will explain what I am doing there.
This is a known bug. It is fixed in 2017, but not yet backported, though I’ve been told it will be. While changing some settings will make it less likely, it cannot be avoided, so I’d suggest not releasing a game based on 5.6 until this is fixed because eventually it will happen.
People often will make mistakes about bugs, unity gets it all the time from people who say “oh but you said my bug would be fixed” but it turns out what they thought was their bug wasn’t, because they didn’t file a bug report and assumed they didn’t.
So if in doubt always: a) assume its not fixed until you read your particular case numbers in fixed notes b) assume it will never be fixed if didn’t send them a case
For now we calulate the path using the agent but we dont use the agent for movement and do our own movement, this helps. You must recheck the path more often than needed though at the moment as sometimes a path returns as invalid when it is not, for some bogus reason re-querying will return the valid path.
I had the same problem here (unity 2019.3.10)
and ended up making a work around:
Disable the agent.update rotation and agent.update position, move the character by using rigidbody.movePosition
and than, just ‘updates’ the agent position with : agent.nextPosition(rigidbody.position)
for my game it works fine, since I’m controlling the player, and this lets me have a more fluid control over it.
Nav mesh agent going arround to nav mesh surface node point… As all my agents go in 1 single direction, i can “easy detect” when they are weird, but its consuming me a lot of CPU as i have hundreds of units…
It seems to have something to do with the agent moving onto an other area before passing one of the nodes in their path? Since they think they missed the node they try to back out of the area, but overshoot and get stuck in a loop like this.