Navigation mesh baked in script is different from the one done in editor

Godot Version

4.3

Question

Hello friends,

I encountered an issue that navigation mesh baked in script is different from the one done in editor. The mesh baked in script looks wrong:



I suspected the baking script had a different settings, like cell size, etc., with the one in editor. But after some investigation, I found all of them were default values.

Any idea? Thanks!

Besides, I also changed the code to use async callback to make sure parsing and baking is finished like the this:

func _ready() -> void:
	if node.name == "navigation":
		nav_mesh = NavigationMesh.new()
		nav_mesh_data = NavigationMeshSourceGeometryData3D.new()
		NavigationMeshGenerator.parse_source_geometry_data(nav_mesh, nav_mesh_data, node, Callable(self, "_on_navi_mesh_parsed"))

func _on_navi_mesh_parsed() -> void:
	NavigationServer3D.bake_from_source_geometry_data_async(nav_mesh, nav_mesh_data, Callable(self, "_on_navi_mesh_baked"))
	print("Navi mesh PARSED!")
	
func _on_navi_mesh_baked() -> void:
	%NavigationRegion.navigation_mesh = nav_mesh
	print("Navi mesh BAKED!")

But no luck, I got same ‘wrong’ navigation mesh.

More info posted. It looks the ‘wrong’ version is actually the default result? But the ‘correct’ version is the one accurately reflects the geometry I did in Blender and indeed it allows Navigation Agent find correct path to move into/out of the house.