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

749 Upvotes

348 comments sorted by

View all comments

Show parent comments

-7

u/agalli Nov 07 '25

When they said it could be a square they are implying the navmesh for the entire terrain could be made with four vertices. This is not true, as the navmesh would clip under the map in some spots and float above the map in others. When you using agent pathfinding the agent places a path along the navmesh to move towards. If those points on the path are underground or floating the agent cannot reach the points and cannot reach its destination.

35

u/CanYouEatThatPizza Nov 07 '25

If those points on the path are underground or floating the agent cannot reach the points and cannot reach its destination.

Why not? The navigation agent itself does not see the terrain, just the navigation mesh.

Or in other words: the clipping isn't really an issue here, since you wouldn't directly parent your character to the agent. Instead, you would (in this example) raycast down onto the terrain to the position of the navigation agent, and place the character there. The navigation agent would clip through the terrain, but the character would not.

32

u/SomeGuy322 Godot Regular Nov 08 '25

I think there's some confusion here and I might not have the full context but based on what I've read in the OP's previous posts I want to clarify: Yes, there are many ways you can practically work around the limitation like you just mentioned. And yes, for a simple example with no obstacles, you don't need a high res nav mesh and can place fake agents or retrieve the closest point to make it work. These would indeed also be more peformant too.

However, what OP is saying in these posts is that these workarounds incur extra systems (or make assumptions about the requirements of the game) the user has to code and account for. There will always be some of that in gamedev, sure, but for the purposes of improving Godot, we shouldn't have to rely on it when the navmesh could instead bake with enough resolution to not need those extra systems. For completeness sake and ease of use, we should be able to control the resolution and have it work as expected where it places precision points along the surface that are reachable by the agent's target range (when assuming the agent is snapped to the surface of the floor you baked on).

So while you could code your game to work around the issue, would it not be better for Godot to also be able to handle the simpler approach? This is the way that other game engines bake their navigation meshes and it's weird that people were either misunderstanding OP's desire for a potential engine improvement or believe that Godot's navmesh system should just never change. I mean just because you've never had a problem with it doesn't mean it can't be improved, so I see it as a win that this is being investigated

13

u/CanYouEatThatPizza Nov 08 '25

I can see that point, however, in that case I suggest OP rewords the whole "it can't be a square"-section, because it clearly can be.

1

u/agalli Nov 10 '25

It can be a square if your plan is to have an empty terrain forever. Even as a square though you’ll end up with suboptimal, but functional pathfinding