Tons of KeyNotFoundException warnings resulting in a Too Many Perturbations Error

Some background: Currently using Pro version 4.3.47. Our project has been suffering from a lot of KeyNotFoundExceptions consistently and finally, the dreaded Too Many Perturbations error started appearing.

I know that this error is the result of too many of such warnings that appear, and I want to check if there are any best practices to prevent any of these warnings.

Here’s a list of points that describe how the NavMesh in our game are being set up:

  1. Our game is a procedural dungeon crawler, which pieces of rooms are stitched together, and then the boundary of the entire map is scanned to create the NavMesh
  2. The combined floor (walking NavMesh) have colliders and a unique layer to be detected and scanned by the Recast graph. They can overlap at times or share edges/points. Their shapes are all rectangular and not rotated in any way.
  3. All props such as walls and barrels that block the player have a NavMeshCut components. They are disabled before the scanning starts, and reactivated after the scanning ends. That’s where all the KeyNotFoundExceptions appear.
  4. The walls, like the floor, are arranged in a way that conforms to a regular grid. The NavMeshCut components have a buffer that’s consistently bigger than visuals, so walls being placed beside each other will have their NavMeshCut bounds overlapping.
  5. The barrels and other obstacles are not placed according to the grid and the overlapping are probably more complex compared to the walls.
  6. There are a lot of walls, barrels and other obstacles in the scene (Averaging 900).

I have a realization while writing this that it might just be the copious amount of overlapping between NavMeshCuts that cause the warnings to happen. I.e. Some regions are cut out by 3 different NavMeshCuts. There’s probably other places that has more trying to cut out the same space.
image

A lot of warnings are thrown by the walls alone; I’ve disabled all barrels and obstacles, leaving only the walls.

Any thoughts on this?

Hi

Yeah I’m really getting tired of the 3rd party libraries I’m using for triangulation. I’ll probably end up rewriting those to make this more robust.
In any case, I think you are right that all the overlapping navmesh cuts help cause the issue. More specifically, this error often happens when they overlap exactly at an edge or a corner. Maybe you could change the sizes of the cuts slightly to make them not touch exactly at edges and corners?