navigation_connecting_navmesh.rst 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. .. _doc_navigation_connecting_navmesh:
  2. Connecting NavigationMeshes
  3. ===========================
  4. Different NavigationMeshes are automatically merged by the NavigationServer
  5. when at least two vertex positions of one edge exactly overlap.
  6. .. image:: img/navigation_vertex_merge.png
  7. The same is true for multiple NavigationPolygon resources. As long as their
  8. outline points overlap exactly the NavigationServer will merge them.
  9. NavigationPolygon outlines must be from different NavigationPolygon resources to connect.
  10. Overlapping or intersecting outlines on the same NavigationPolygon
  11. will fail the navigation mesh creation. Overlapping or intersecting
  12. outlines from different NavigationPolygons will often fail to create the
  13. navigation region edge connections on the NavigationServer and should be avoided.
  14. .. image:: img/navigation_vertex_merge2.png
  15. .. warning::
  16. Exactly means exactly for the vertex position merge. Small float errors
  17. that happen quite regularly with imported meshes will prevent a successful vertex merge.
  18. Alternatively ``NavigationMesh``s are not merged but still considered as ``connected`` by
  19. the NavigationServer when their edges are nearly parallel and within distance
  20. to each other. The connection distance is defined by the ``edge_connection_margin`` for each
  21. navigation map. In many cases NavigationMesh edges cannot properly connect when they partly overlap.
  22. Better avoid any navigation mesh overlap at all time for a consistent merge behavior.
  23. .. image:: img/navigation_edge_connection.png
  24. If navigation debug is enabled and the NavigationServer active the established navigation mesh connections will be visualized.
  25. See :ref:`doc_navigation_debug_tools` for more info about navigation debug options.
  26. The default 2D ``edge_connection_margin`` can be changed in the ProjectSettings under ``navigation/2d/default_edge_connection_margin``.
  27. The default 3D ``edge_connection_margin`` can be changed in the ProjectSettings under ``navigation/3d/default_edge_connection_margin``.
  28. The edge connection margin value of any navigation map can also be changed at runtime with the NavigationServer API.
  29. .. tabs::
  30. .. code-tab:: gdscript GDScript
  31. extends Node2D
  32. # 2D margins are designed to work with "pixel" values
  33. var default_2d_map_rid : RID = get_world_2d().get_navigation_map()
  34. NavigationServer2D.map_set_edge_connection_margin(default_2d_map_rid, 50.0)
  35. .. tabs::
  36. .. code-tab:: gdscript GDScript
  37. extends Node3D
  38. # 3D margins are designed to work with 3D unit values
  39. var default_3d_map_rid : RID = get_world_3d().get_navigation_map()
  40. NavigationServer3D.map_set_edge_connection_margin(default_3d_map_rid, 0.5)
  41. .. note::
  42. Changing the edge connection margin will trigger a full update of all navigation mesh connections on the NavigationServer.