diff --git a/doc/classes/Navigation2DServer.xml b/doc/classes/Navigation2DServer.xml
index 1e3a4aa6e..6c7d57af4 100644
--- a/doc/classes/Navigation2DServer.xml
+++ b/doc/classes/Navigation2DServer.xml
@@ -347,7 +347,7 @@
- Returns the map cell size.
+ Returns the map cell size used to rasterize the navigation mesh vertices.
@@ -447,7 +447,7 @@
- Set the map cell size used to weld the navigation mesh polygons.
+ Sets the map cell size used to rasterize the navigation mesh vertices. Must match with the cell size of the used navigation meshes.
diff --git a/doc/classes/NavigationMesh.xml b/doc/classes/NavigationMesh.xml
index 0a24413d8..ca1dbdaf4 100644
--- a/doc/classes/NavigationMesh.xml
+++ b/doc/classes/NavigationMesh.xml
@@ -103,10 +103,10 @@
[b]Note:[/b] While baking, this value will be rounded up to the nearest multiple of [member cell_size].
- The Y axis cell size to use for fields.
+ The cell height used to rasterize the navigation mesh vertices on the Y axis. Must match with the cell height on the navigation map.
- The XZ plane cell size to use for fields.
+ The cell size used to rasterize the navigation mesh vertices on the XZ plane. Must match with the cell size on the navigation map.
The sampling distance to use when generating the detail mesh, in cell unit.
diff --git a/doc/classes/NavigationServer.xml b/doc/classes/NavigationServer.xml
index e1cdde8c3..e50559095 100644
--- a/doc/classes/NavigationServer.xml
+++ b/doc/classes/NavigationServer.xml
@@ -369,16 +369,16 @@
-
+
- Returns the map cell height.
+ Returns the map cell height used to rasterize the navigation mesh vertices on the Y axis.
- Returns the map cell size.
+ Returns the map cell size used to rasterize the navigation mesh vertices on the XZ plane.
@@ -495,7 +495,7 @@
- Set the map cell height used to weld the navigation mesh polygons.
+ Sets the map cell height used to rasterize the navigation mesh vertices on the Y axis. Must match with the cell height of the used navigation meshes.
diff --git a/modules/navigation/nav_map.cpp b/modules/navigation/nav_map.cpp
index e656074ba..ed0f50c57 100644
--- a/modules/navigation/nav_map.cpp
+++ b/modules/navigation/nav_map.cpp
@@ -1352,8 +1352,9 @@ void NavMap::clip_path(const LocalVector &p_navigation_polys
NavMap::NavMap() {
up = Vector3(0, 1, 0);
- cell_size = 0.25;
- cell_height = 0.25;
+ /// each cell has the following cell_size and cell_height.
+ cell_size = 0.25; // Must match ProjectSettings default 3D cell_size and NavigationMesh cell_size.
+ cell_height = 0.25; // Must match ProjectSettings default 3D cell_height and NavigationMesh cell_height.
edge_connection_margin = 0.25;
regenerate_polygons = true;
regenerate_links = true;
diff --git a/modules/navigation/nav_region.cpp b/modules/navigation/nav_region.cpp
index 6c1f11bbe..00f2fe011 100644
--- a/modules/navigation/nav_region.cpp
+++ b/modules/navigation/nav_region.cpp
@@ -113,6 +113,10 @@ void NavRegion::update_polygons() {
ERR_PRINT_ONCE(vformat("Navigation map synchronization error. Attempted to update a navigation region with a navigation mesh that uses a `cell_size` of %s while assigned to a navigation map set to a `cell_size` of %s. The cell size for navigation maps can be changed by using the NavigationServer map_set_cell_size() function. The cell size for default navigation maps can also be changed in the ProjectSettings.", double(map->get_cell_size()), double(mesh->get_cell_size())));
}
+ if (!Math::is_equal_approx(double(map->get_cell_height()), double(mesh->get_cell_height()))) {
+ ERR_PRINT_ONCE("Navigation map synchronization error. Attempted to update a navigation region with a navigation mesh that uses a different `cell_height` than the `cell_height` set on the navigation map.");
+ }
+
if (map && Math::rad2deg(map->get_up().angle_to(transform.basis.get_column(1))) >= 90.0f) {
ERR_PRINT_ONCE(vformat("Navigation map synchronization error. Attempted to update a navigation region with a navigation mesh that uses a `cell_height` of %s while assigned to a navigation map set to a `cell_height` of %s. The cell height for navigation maps can be changed by using the NavigationServer map_set_cell_height() function. The cell height for default navigation maps can also be changed in the ProjectSettings.", double(map->get_cell_height()), double(mesh->get_cell_height())));
}
diff --git a/scene/resources/navigation_mesh.cpp b/scene/resources/navigation_mesh.cpp
index 7004c0f4a..c54363f8c 100644
--- a/scene/resources/navigation_mesh.cpp
+++ b/scene/resources/navigation_mesh.cpp
@@ -641,8 +641,8 @@ void NavigationMesh::_validate_property(PropertyInfo &property) const {
}
NavigationMesh::NavigationMesh() {
- cell_size = 0.25f;
- cell_height = 0.25f;
+ cell_size = 0.25f; // Must match ProjectSettings default 3D cell_size and NavigationServer NavMap cell_size.
+ cell_height = 0.25f; // Must match ProjectSettings default 3D cell_height and NavigationServer NavMap cell_height.
agent_height = 1.5f;
agent_radius = 0.5f;
agent_max_climb = 0.25f;
diff --git a/scene/resources/navigation_polygon.cpp b/scene/resources/navigation_polygon.cpp
index b46f4336e..172b60ae9 100644
--- a/scene/resources/navigation_polygon.cpp
+++ b/scene/resources/navigation_polygon.cpp
@@ -426,7 +426,7 @@ RID NavigationPolygon::get_rid() const {
NavigationPolygon::NavigationPolygon() {
agent_radius = 10.0f;
- cell_size = 1.0f;
+ cell_size = 1.0f; // Must match ProjectSettings default 2D cell_size.
parsed_geometry_type = PARSED_GEOMETRY_MESH_INSTANCES;
collision_mask = 0xFFFFFFFF;