Up to date
This page is up to date for Godot 4.2
.
If you still find outdated information, please open an issue.
Navigation debug tools¶
備註
偵錯工具、屬性和函式僅在 Godot 偵錯版本中可用。不要在發布版本的程式碼中使用它們中的任何一個。
Enabling navigation debug¶
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.
In Godot debug builds the navigation debug can also be toggled through the NavigationServer singletons from scripts.
NavigationServer2D.set_debug_enabled(false)
NavigationServer3D.set_debug_enabled(true)
Navigation debug settings¶
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.
建立內容¶
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
.
測試¶
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
.
備註
只有當導覽伺服器處於活動狀態時,邊緣連線才可見。
Debug performance¶
To measure NavigationServer performance a dedicated monitor exists that can be found within the Editor Debugger under Debugger->Monitors->Navigation Process.
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.
導覽還提供了關於目前導覽相關物件和導覽伺服器上導覽地圖組成的更詳細的統計資料。
此處顯示的導覽統計資料無法判斷性能的好壞,因為它完全取決於專案什麼可以被認為是合理的或嚴重過度的。
導覽統計資訊有助於識別不太明顯的效能瓶頸,因為來源可能並不總是具有可見的表示形式。例如,由具有數千個邊/多邊形的過於詳細的導覽網格所建立的尋路效能問題,或由程式導覽出錯所引起的問題。