Godot Version
4.3
Question
The following scene contains a NavigationRegion2D
with 2 polygons child nodes. I’ve set the agent radius to 0 and the way the polygons are arranged produces an error after baking the navigation polygon. The full error is:
E 0:00:01:0057 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()
but I don’t think any of this things apply.
You can also reproduce the scene with a script:
extends Node2D
var navigation_region = NavigationRegion2D.new()
func _ready() -> void:
navigation_region.navigation_polygon = NavigationPolygon.new()
var agent_radius = 0
navigation_region.navigation_polygon.baking_rect = Rect2(
0,
0,
500,
500,
)
navigation_region.navigation_polygon.agent_radius = 0
var source_geometry_data = NavigationMeshSourceGeometryData2D.new()
source_geometry_data.add_traversable_outline([
Vector2(0, 0),
Vector2(500, 0),
Vector2(500, 500),
Vector2(0, 500),
])
for j in range(1, 5):
for i in range(1, 5):
var top_left = Vector2(i * 100 - 50, j * 100 - 50)
var bottom_right = Vector2(i * 100 + 50, j * 100 + 50)
var outline = [
top_left,
Vector2(bottom_right.x, top_left.y),
bottom_right,
Vector2(top_left.x, bottom_right.y),
top_left
]
if (
(i == 1 and j == 1)
or (i == 2 and j == 2)
):
source_geometry_data.add_obstruction_outline(outline)
add_child(navigation_region)
NavigationServer2D.bake_from_source_geometry_data(
navigation_region.navigation_polygon,
source_geometry_data
)
This script also shows that the baked region is problematic:
it doesn’t produce an error though.