导航调试工具

备注

调试工具、调试属性、调试函数都只在调试版本的 Godot 中可用,请勿在发布版本的代码中使用。

启用调试导航

The navigation debug visualizations are enabled by default inside the editor. To visualize navigation meshes and connections at runtime too, enable the option Visible Navigation in the editor Debug menu.

../../_images/navigation_debug_toggle.png

In Godot debug builds the navigation debug can also be toggled through the NavigationServer singletons from scripts.

GDScript

  1. NavigationServer2D.set_debug_enabled(false)
  2. NavigationServer3D.set_debug_enabled(true)

导航调试设置

The appearance of navigation debug can be changed in the ProjectSettings under debug/shapes/navigation. Certain debug features can also be enabled or disabled at will but may require a scene restart to take effect.

../../_images/nav_debug_settings.png

调试导航网格多边形

If enable_edge_lines is enabled, the edges of navigation mesh polygons will be highlighted. If enable_edge_lines_xray is also enabled, the edges of navigation meshes will be visible through geometry.

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.

../../_images/nav_debug_xray_edge_lines.png

调试边缘连接

When two navigation meshes are connected within edge_connection_margin distance, the connection is overlaid. The color of the overlay is controlled by edge_connection_color. The connections can be made visible through geometry with enable_edge_connections_xray.

../../_images/nav_edge_connection2d.gif ../../_images/nav_edge_connection3d.gif

备注

Edge connections are only visible when the NavigationServer is active.

调试性能

To measure NavigationServer performance a dedicated monitor exists that can be found within the Editor Debugger under Debugger->Monitors->Navigation Process.

../../_images/navigation_debug_performance1.webp

Navigation Process shows how long the NavigationServer spends updating its internals this update frame in milliseconds. Navigation Process works similar to Process for visual frame rendering and Physics Process for collision and fixed updates.

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.

备注

Navigation Process does NOT include pathfinding performance cause pathfinding operates on the navigation map data independently from the server process update.

Navigation Process should be in general kept as low and as stable as possible for runtime performance to avoid frame rate issues. 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.

Navigation also provides more detailed statistics about the current navigation related objects and navigation map composition on the NavigationServer.

../../_images/navigation_debug_performance2.webp

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.

Navigation statistics help with identifying performance bottlenecks that are less obvious because the source might not always have a visible representation. E.g. pathfinding performance issues created by overly detailed navigation meshes with thousand of edges / polygons or problems caused by procedural navigation gone wrong.

Previous Next


© 版权所有 2014-present Juan Linietsky, Ariel Manzur and the Godot community (CC BY 3.0). Revision b1c660f7.

Built with Sphinx using a theme provided by Read the Docs.