Hi, I have simple formation system for ally characters in my game. There may be dozens of them hoarding around player.
-
What I noticed is that when they run to player from long distance traversing around obstacles they can suddenly stop, i.e. they just run in a straight line with no other characters around, stop for a moment and continue moving.
-
Second problem happens near very specific places, usually some walls when you approach them from specific side. Again, some units or even single unit don’t stop entirely, but drop speed and approach final destination slowly. What I noticed is its NavMeshAgent velocity gizmo is “jumping” up and down 45 degrees offset instead of being a straight line, i.e it seems like NavMeshAgent can’t decide where to go and constantly reevaluates velocity causing big speed drop.
First problem happens when player is actually moving i.e. formation positions are being recalculated.
And both problems happens only when ObstacleAvoidance is enabled on NavMeshAgents.
Map is static and Player himself don’t interact with NavMesh in any way (simple collider + rigidbody).
Is there a way to fix it without disabling obstacle avoidance (I need characters to avoid each other)?
UPD 1: Btw I just checked and enemies have the same problem, sometimes they stop when chasing player across obstacles.
UPD 2: I checked and disabling obstacle avoidance don’t solve first problem anymore. It’s related to something else. Is it ok that NavMeshAgent stops when destination is being changed?
UPD 3: Ok, I solved the first problem with stopping agents, it was caused by the fact that paths are calculated async and it seems that agents just stop after SetDestination if there are too many of them and/or paths are too long. NavMesh.pathfindingIterationsPerFrame = 10000 solves it (denies benefit of async, but whatever).