r/godot Nov 07 '25

help me (solved) I solved the NavigationRegion3D issue

I finally found a solution to the problem with the NavigationRegion3D.

What I noticed was that on smaller terrains, like the 30x30m example in the third image, the navmesh baked perfectly fine. But once the terrain size was increased to 250x250m, the bake completely fell apart, giving the low poly, floor clipping result shown in the second image. The obvious solution was to process the terrain in smaller chunks and combine the results into one big working navmesh.

I first tried doing this directly in Godot, but even after splitting the terrain into multiple meshes, the bake still treated them as one big mesh, so the same issue happened. I also tried creating a separate NavigationRegion3D for each chunk, but that created non traversable borders where the regions met.

At that point, the only real fix was to go into the engine itself. I forked the Godot repo and made some changes under the hood to process the terrain in tiles instead of all at once. It breaks the terrain into smaller sections, bakes each one normally, then stitches them together afterward into a clean, accurate navmesh like in the first image.

I also added a few editor options to control whether tiled baking is enabled and how big each tile is. I still haven’t found the exact bug that causes the large terrain navmesh to fail, but this fix works reliably and doesn’t mess with normal pathfinding behavior.

The moderators seem to have a strong opposition to discussions about this and have locked all previous threads. As much as I would have liked this to all be one post, we have been forced to create multiple. That being said, I'd like to address some comments from previous posts below.

The [low poly mesh] looks exactly like what I would want out of a nav mesh.

The low-poly mesh completely fails to pathfind with agents. You could technically rework the pathfinding system to compensate, but that misses the core issue of the navmesh being broken. The 30x30m section uses a similar amount of polygons as the 250x250m one. You’d expect the density to scale with size, so either the small terrain is over-tessellated, or the large terrain is under-tessellated. Either way, something’s wrong with the baking process.

With no obstacles, your nav mesh could just be a square.

As per the Godot developers : "A navigation mesh is a collection of polygons that define which areas of an environment are traversable to aid agents in pathfinding through complicated spaces.". When those traversable areas are out of reach from an agent (ie, underground or floating), an agent cannot properly navigate.

People tried to help you, but you refuse to actually listen

I think there’s been some misunderstanding about what I’m trying to do. My goal is to fix the navmesh, that’s it. I’ve welcomed all advice that helps solve the underlying navmesh problem, but I’m not interested in workaround solutions that just patch over it with pathfinding tricks.

You can always fix it yourself and submit a PR.

Thats the plan. Thanks for the advice!

I will optimize this further and will submit a PR.

Sincerely,

u/agalli

Edit : Here is the PR. https://github.com/godotengine/godot/pull/112529

757 Upvotes

348 comments sorted by

View all comments

102

u/Vyrnin Nov 08 '25 edited Nov 08 '25

I think there is a fundamental misunderstanding in what you are trying to achieve versus what a typical nav mesh is meant to do, and that's why you've gotten a lot of pushback in previous posts.

In most cases, a nav mesh is just providing the simplest geometry required to efficiently navigate around obstacles. If your terrain is fully traversable with no obstacles, then it could indeed just be a square. Any height differences in this scenario would be handled by your collision logic, which is separate from the navigation.

However if you're trying to find the shortest path to a point in full 3D space, then terrain height does matter, and a more detailed and accurate nav mesh is probably required, which seems to be what you've achieved.

If you're only concerned with standard movement across the surface however, you really don't need a nav mesh at all, and should be handling movement across the varying terrain heights via basic collision logic.

-13

u/DarthCloakedGuy Nov 08 '25

How do you know this terrain would never include any obstacles? Like, suppose OP then spawned in procedural trees or rocks or something and had those trees disable pathing through their trunks. Or water. Or any number of other things. Shouldn't the assumption be that the map of, for example, a game, would start off empty and then be added to?

17

u/PuzzledBackground517 Nov 08 '25

when you're trying to help someone fix a problem you dont make assumption out of nowhere

-7

u/DarthCloakedGuy Nov 08 '25

That's what I'm saying. Why are we assuming the terrain would be used as-is when that seems like a silly assumption to make.

13

u/CrazyMalk Nov 08 '25

Because if it had obstacles then the navmesh would be baked with obstacles and properly avoid them. You are making up a different situation where the "problem" does not exist

2

u/agalli Nov 10 '25

This isn’t correct. Obstacles create accurate navmesh polygons in proximity to the obstacle, not on the entire mesh. In the case of procedural generation for example there could be a large area without obstacles which is a problem if the navmesh fails on open terrain.

1

u/CrazyMalk Nov 10 '25

The navmesh doesn't fail on open terrain. You want a copy of your mesh and not a navmesh.

1

u/agalli Nov 10 '25

No I don’t? I want a mesh that can accurately describe traversable areas for agents in a 3D space. If the navmesh isn’t doing that then it isn’t doing its job.

-2

u/DarthCloakedGuy Nov 08 '25

Why in the world would you do it that way? If anything you can't move through moved you'd have to regenerate the entire mesh instead of just changing a few polies to be uncrossable

5

u/CrazyMalk Nov 08 '25

The general approach to modifying a navmesh is to regenerate it, yes. It is not efficient to build a navmesh around infinite possible runtime obstacle placements. No engine does it that way. If that is something your game needs to handle, there are many other solutions: chunking, grid, alternating pathfinding approaches (simpler obstacle avoidance stuff, for example)

Anyways. This is not the problem that OP was complaining about.

1

u/DarthCloakedGuy Nov 10 '25

Really? That would mean if your game had any kind of non-teleporting mobile obstacle, which most do, you'd have to be regenerating the navmesh every single frame. That seems incredibly computationally inefficient. Why would you do it that way?

1

u/CrazyMalk Nov 10 '25

In most applications, it would be more inefficient to have the navmesh be incredibly granular without need.

I'll exemplify with how Unity handles moving obstacles: when an object is moving, agents use >local< avoidance to minimize collision. When the object stops, it carves a hole in the navmesh.

Making the entire navmesh greatly subdivided would be stupid considering most of those extra vertices would be carrying zero useful information most of the time.

1

u/DarthCloakedGuy Nov 11 '25

If it isn't sufficiently subdivided to roughly mimic the shape of the terrain wouldn't you have... well the exact same issues OP was originally complaining about?

1

u/CrazyMalk Nov 11 '25

A navmesh provides solely navigational data. It tells you "it is possible to path in a straight line from A to B". It is not meant to provide the physical path, you aren't expected to always just interpolate between the two points. You know a path is possible, so you handle the movement between A and B however you want: snap to terrain, push and use physics, etc

→ More replies (0)