navigation_debug_tools.rst 4.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. .. _doc_navigation_debug_tools:
  2. Navigation debug tools
  3. ======================
  4. .. note::
  5. The debug tools, properties and functions are only available in Godot debug builds.
  6. Do not use any of them in code that will be part of a release build.
  7. Enabling navigation debug
  8. -------------------------
  9. The navigation debug visualizations are enabled by default inside the editor.
  10. To visualize navigation meshes and connections at runtime too, enable the option **Visible Navigation** in the editor **Debug** menu.
  11. .. image:: img/navigation_debug_toggle.png
  12. In Godot debug builds the navigation debug can also be toggled through the NavigationServer singletons from scripts.
  13. .. tabs::
  14. .. code-tab:: gdscript GDScript
  15. NavigationServer2D.set_debug_enabled(false)
  16. NavigationServer3D.set_debug_enabled(true)
  17. .. code-tab:: csharp
  18. NavigationServer2D.SetDebugEnabled(false);
  19. NavigationServer3D.SetDebugEnabled(true);
  20. Debug visualizations are currently based on Nodes in the SceneTree. If the :ref:`NavigationServer2D<class_NavigationServer2D>` or :ref:`NavigationServer3D<class_NavigationServer3D>`
  21. APIs are used exclusively then changes will not be reflected by the debug navigation tools.
  22. Navigation debug settings
  23. -------------------------
  24. The appearance of navigation debug can be changed in the ProjectSettings under ``debug/shapes/navigation``.
  25. Certain debug features can also be enabled or disabled at will but may require a scene restart to take effect.
  26. .. image:: img/nav_debug_settings.png
  27. Debug navigation mesh polygons
  28. ------------------------------
  29. If ``enable_edge_lines`` is enabled, the edges of navigation mesh polygons will be highlighted.
  30. If ``enable_edge_lines_xray`` is also enabled, the edges of navigation meshes will be visible through geometry.
  31. If ``enable_geometry_face_random_color`` is enabled, the color of each navigation mesh face will be mixed with a random color that is itself mixed with the color specified in ``geometry_face_color``.
  32. .. image:: img/nav_debug_xray_edge_lines.png
  33. Debug edge connections
  34. ----------------------
  35. When two navigation meshes are connected within ``edge_connection_margin`` distance, the connection is overlaid.
  36. The color of the overlay is controlled by ``edge_connection_color``.
  37. The connections can be made visible through geometry with ``enable_edge_connections_xray``.
  38. .. image:: img/nav_edge_connection2d.gif
  39. .. image:: img/nav_edge_connection3d.gif
  40. .. note::
  41. Edge connections are only visible when the NavigationServer is active.
  42. Debug performance
  43. -----------------
  44. To measure NavigationServer performance a dedicated monitor exists that can be found within the Editor Debugger under *Debugger->Monitors->Navigation Process*.
  45. .. image:: img/navigation_debug_performance1.webp
  46. Navigation Process shows how long the NavigationServer spends updating its internals this update frame in milliseconds.
  47. Navigation Process works similar to Process for visual frame rendering and Physics Process for collision and fixed updates.
  48. Navigation Process accounts for all updates to **navigation maps**, **navigation regions** and **navigation agents** as well as all the **avoidance calculations** for the update frame.
  49. .. note::
  50. Navigation Process does NOT include pathfinding performance cause pathfinding operates on the navigation map data independently from the server process update.
  51. Navigation Process should be in general kept as low and as stable as possible for runtime performance to avoid frame rate issues.
  52. Note that since the NavigationServer process update happens in the middle of the physics update an increase in Navigation Process will automatically increase Physics Process by the same amount.
  53. Navigation also provides more detailed statistics about the current navigation related objects and navigation map composition on the NavigationServer.
  54. .. image:: img/navigation_debug_performance2.webp
  55. Navigation statistics shown here can not be judged as good or bad for performance as it depends entirely on the project what can be considered as reasonable or horribly excessive.
  56. Navigation statistics help with identifying performance bottlenecks that are less obvious because the source might not always have a visible representation.
  57. E.g. pathfinding performance issues created by overly detailed navigation meshes with thousand of edges / polygons or problems caused by procedural navigation gone wrong.