Problem with navigation layers in tilemaplayer

Godot Version

4.3

Question

Hi, I’m working on a top-down RTS game, my problem is if I have overlapping navigation I get an error
I want different heights in my game

E 0:00:01:0521   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.
  <C++ Source>   modules/navigation/nav_map.cpp:990 @ sync()

I tried different navigation layers but still have the same issues

any solution?

Navigation meshes can not overlap on the same navigation map, it is a logical error if they do.

So if you need 2D “height” you either use 3D navigation or you create different “2D” navigation maps for each height and juggle agents between them.

Or you can switch to simple point navigation with AStar2D. Because this kind of navigation has no surfaces, just points, it does not care about overlap too much as long as the point connections make sense.

so how to make different navigation map in tilemaplayer?

You can create and activate a new navigation map with the NavigationServer2D and set the navigation map on a TileMapLayer. Then you also set this map on all the agents that should use it for their pathfinding. See NavigationRegion2D on different layers affecting each other? - #4 by smix8

so I need just collect tilemap navigation data, remove them, create a new navigation region, and call set_navigation_map?
wait, an agent just can have 1 active navigation map? mean for each floor change I need to call set_navigation_map for agents?

No need to remove things, you can just call TileMapLayer.set_navigation_map().

Yes, you need to switch agents for a “floor” change.

2D throws all the navigation mesh polygons over each other when on the same map because there is no real verticality axis like in 3D. If all the polygons just randomly overlap and intersect how should pathfinding still function, all that surface logic no longer makes any sense at that point.

I created a new script for my tilemap layers, but the error still exists:

class_name Ground
extends TileMapLayer

func _ready() -> void:
	var map: RID = NavigationServer2D.map_create()
	set_navigation_map(map)