How to handle doors (ie, turn parts of the nav mesh off and on)?

Godot Version

v4.3.stable.official [77dcf97d8]

Question

I’m new to using navigation meshes. I’m creating a 3D game of an indoor space with many rooms, some of which have doors that can open and close.

When I try to calculate a path from one place to another, it would be nice if they could take into account whether or not a door is open. If so, they could create a path that goes through the door and if not, either find another route or indicate that no route exists. Is this possible? I was looking at the NavigationObsticle3D, but wasn’t sure if it would be useful.

If you can split your level into multiple regions where each door has its own mini region you can use the navigation_layers bitmask to toggle a door as open / closed or whatever “key” it needs to be used. Then use that bitmask as a polygon filter in the path queries or NavigationAgent. Using the navigation layers bitmask for this avoids rebaking the navmesh so it is more performant to do for runtime changes.

How would I break my mesh apart like that? The baking tool just creates a single nav mesh for me. Do you mean I should create multiple nav meshes for different rooms of the level? How would I join them together?

Navigation meshes join automatically when their edges overlap. So you split up your level geometry and use multiple regions. You can use the navigation mesh baking bounds to limit the area that gets baked so the baking creates edges that are easier to align with the neighbor chunks.