Navigation error after upgrading to Godot 4.3

Godot Version

4.3

Question

I get the following error since opening my project in 4.3:
“E 0:00:01:0219 sync: Navigation map synchronization error. Attempted to merge a navigation mesh polygon edge with another already-merged edge. This is usually caused by crossing edges, overlapping polygons, or a mismatch of the NavigationMesh / NavigationPolygon baked ‘cell_size’ and navigation map ‘cell_size’. If you’re certain none of above is the case, change ‘navigation/3d/merge_rasterizer_cell_scale’ to 0.001.”
"
I upgraded to 4.3 to replace my TileMaps with TileMapLayers to allow me usage of shader materials for each layer. I have PackedScene instances for parts of my map. Using a level generator I combine those scenes together. Each of those contains a TileMap (didnt replace them with TileMapLayers yet), NavigationRegion2D and some scenes that represent obstacles. Those scenes are child nodes of NavigationRegion2D and during level generation I bake navigation area for each scene (part of map). I use Edge Connections checkbox on each PackedScene and also set the edge connection margin to 20.0 in level generation code:

func generate_level(level_difficulty_param):
	var island_spawn_pos = Vector2(0,0)
	var dimensions = [2, 2]
	while dimensions[0] < 3 and dimensions[1] < 3:
		dimensions = calculate_island_dimensions(level_difficulty_param)
	var _island = await generate_island(dimensions[0], dimensions[1], island_spawn_pos.x, island_spawn_pos.y)
	var enemy_spawn_positions = get_enemy_spawn_positions()
	var defence_spawn_positions = get_enemy_spawn_positions(true)
	GlobalSignals.emit_signal("spawn_positions_defined", enemy_spawn_positions, dimensions)
	GlobalSignals.emit_signal("spawn_defence_positions_defined", defence_spawn_positions, dimensions)
	await bake_navigation_regions()
	# set edge connection margin to connect neighbouring navigation regions, otherwise there would be an untraversable gap
	var default_2d_map_rid: RID = get_world_2d().get_navigation_map()
	NavigationServer2D.map_set_edge_connection_margin(default_2d_map_rid, 20.0)
func bake_navigation_regions():
	for nav_region: NavigationRegion2D in nav_regions:
		nav_region.bake_navigation_polygon(true)

That error is because the created navigation mesh had edges with points that did all fall into the same navigation map rasterization cells, creating merge conflicts as only 2 edges can pair up for the same position while 2+ edges are logical errors in the navmesh. The most common cause for this are navmesh polygon overlaps. If you use a NavigationRegion2D make sure that nothing else adds a navmesh as well, e.g. TileMap build-in navigation is not enabled.

1 Like