bake_navigation_polygon() makes whole NavigationRegion2D disappear

Godot 4.4

Trying to get the very basics of navigation meshes to work.

var TempNavMesh = NavigationPolygon.new()
	var Vertices = PackedVector2Array([Vector2(0,0), Vector2(WorldWidth*32,0), Vector2(WorldWidth*32,WorldHeight*32), Vector2(0,WorldHeight*32)])
	TempNavMesh.vertices = Vertices
	var TempNavMeshIndices = PackedInt32Array([0,1,2,3])
	TempNavMesh.add_polygon(TempNavMeshIndices)
	$NavigationRegion2D.navigation_polygon = TempNavMesh

This works; creates a big mesh across the whole world.

var NewPolygon = Polygon2D.new()
	$NavigationRegion2D.add_child(NewPolygon)
	Vertices = PackedVector2Array([Vector2(5000,5000), Vector2(10000,5000), Vector2(10000,10000), Vector2(5000,10000)])
	NewPolygon.polygon = Vertices
	$NavigationRegion2D.bake_navigation_polygon()

Adding this block makes the whole region disappear. Just trying to create a square hole in the middle of the mesh.

Removing the whole second block except ‘$NavigationRegion2D.bake_navigation_polygon()’ gives the same result. bake_navigation_polygon() seems to make the entire mesh disappear.

For some reason everything works fine outside of scripts.


The two tiles with a physics layer painted on are removed from the mesh when I click ‘Bake NavigationPolygon’.

Just trying to figure out why it works in the main editor but not with a script.