Instantiating a nav mesh obstacle makes all current nav mesh agents try to walk through a wall.

In summary, I am making a game with tower-defence elements, with creeps that use a navigation mesh to pathfind their way to the enemy base. The main issue is, when I create a tower that’s nearby the path they would take, most of the creeps try to just turn around and try to force themselves through a wall, until they get pushed out by some other creep trying to do the same thing.

The towers have a Nav Mesh Obstacle component with “Carve” enabled (because otherwise they’d just stop in front of said tower), and I feel that it’s re-generating the polygons that the navmesh is made of, and in that frame, the creeps AI just breaks. I have no clue how to fix this problem, any assistance or advice would be greatly appreciated.

Here’s a video showing the problem, for those that need to see the issue to understand it (I wouldn’t blame you).


Seems like creating a navmesh obstacle with carving at runtime invalidates the existing paths. You can try setting carve only stationary on, or disabling carving, or tell all of your navmesh agents to calculate a new path (with SetDestination()) when you place a new obstacle. I don’t know if either will help, but based on my experience with navmeshes these could solve the issue.


As none of these suggestions seem to help, maybe you can look into Unity’s NavMesh Components which extends the navmesh functionality, or completely switch over to the A* star project (you don’t have to buy the pro, the free version is already useful enough).

Sorry I can’t give you better advice, I’ve been working with navmeshes for 2 years and they still don’t always do what I want them to do (I’m looking at you, distance from destination logic >:( ).

Hi @Pizzaboy10,

I have the same problem. Have you solved in any way?

I’ll suggest something that will work but it WON’T be performant. You can use a navneshsurface, and rebuild the navmesh each time a new tower is placed. There will be a noticeable stutter if you have a large play area with a high resolution. You’d need to change your towers to “not walkable” and take off the obstacle component. If the user places alot of towers sequentially there’ll be a larger stutter.

Hi @Pizzaboy10,

I have the same problem. Have you solved in any way?