Attention: Here be dragons
This is the latest
(unstable) version of this documentation, which may document features
not available in or compatible with released stable versions of Godot.
Checking the stable version of the documentation...
NavigationServer2D
實驗性: This class may be changed or removed in future versions.
繼承: Object
用於存取低階 2D 導覽的伺服器介面。
說明
NavigationServer2D is the server that handles navigation maps, regions and agents. It does not handle A* navigation from AStar2D or AStarGrid2D.
Maps are divided into regions, which are composed of navigation polygons. Together, they define the traversable areas in the 2D world.
Note: Most NavigationServer2D changes take effect after the next physics frame and not immediately. This includes all changes made to maps, regions or agents by navigation-related nodes in the scene tree or made through scripts.
For two regions to be connected to each other, they must share a similar edge. An edge is considered connected to another if both of its two vertices are at a distance less than edge_connection_margin to the respective other edge's vertex.
You may assign navigation layers to regions with region_set_navigation_layers(), which then can be checked upon when requesting a path with map_get_path(). This can be used to allow or deny certain areas for some objects.
To use the collision avoidance system, you may use agents. You can set an agent's target velocity, then the servers will emit a callback with a modified velocity.
Note: The collision avoidance system ignores regions. Using the modified velocity directly may move an agent outside of the traversable area. This is a limitation of the collision avoidance system, any more complex situation may require the use of the physics engine.
This server keeps tracks of any call and executes them during the sync phase. This means that you can request any change to the map, using any thread, without worrying.
教學
方法
訊號
avoidance_debug_changed() 🔗
當避障除錯設定更改時發出。僅在除錯版本中可用。
當導覽地圖更新時、地區移動或被修改時發出。
navigation_debug_changed() 🔗
當導覽除錯設定更改時發出。僅在除錯版本中可用。
列舉
enum ProcessInfo: 🔗
ProcessInfo INFO_ACTIVE_MAPS = 0
常數,用於獲取活動導覽地圖的數量。
ProcessInfo INFO_REGION_COUNT = 1
常數,用於獲取活動導覽地區的數量。
ProcessInfo INFO_AGENT_COUNT = 2
常數,用於獲取正在進行避障的活動導覽代理的數量。
ProcessInfo INFO_LINK_COUNT = 3
常數,用於獲取活動導覽連結的數量。
ProcessInfo INFO_POLYGON_COUNT = 4
常數,用於獲取導覽網格多邊形的數量。
ProcessInfo INFO_EDGE_COUNT = 5
常數,用於獲取導覽網格多邊形的邊的數量。
ProcessInfo INFO_EDGE_MERGE_COUNT = 6
常數,用於獲取由於邊鍵重疊而被合併的導覽網格多邊形的邊的數量。
ProcessInfo INFO_EDGE_CONNECTION_COUNT = 7
常數,用以獲取被認為由於邊接近而連接的導覽網格多邊形的邊的數量。
ProcessInfo INFO_EDGE_FREE_COUNT = 8
常數,用於獲取無法合併但仍可通過邊接近或連結連接的導覽網格多邊形的邊的數量。
ProcessInfo INFO_OBSTACLE_COUNT = 9
Constant to get the number of active navigation obstacles.
方法說明
建立代理。
bool agent_get_avoidance_enabled(agent: RID) const 🔗
如果指定的 agent 使用避障,則返回 true。
int agent_get_avoidance_layers(agent: RID) const 🔗
Returns the avoidance_layers bitmask of the specified agent.
int agent_get_avoidance_mask(agent: RID) const 🔗
Returns the avoidance_mask bitmask of the specified agent.
float agent_get_avoidance_priority(agent: RID) const 🔗
Returns the avoidance_priority of the specified agent.
RID agent_get_map(agent: RID) const 🔗
返回請求 agent 目前分配到的導覽地圖 RID。
int agent_get_max_neighbors(agent: RID) const 🔗
Returns the maximum number of other agents the specified agent takes into account in the navigation.
float agent_get_max_speed(agent: RID) const 🔗
Returns the maximum speed of the specified agent.
float agent_get_neighbor_distance(agent: RID) const 🔗
Returns the maximum distance to other agents the specified agent takes into account in the navigation.
bool agent_get_paused(agent: RID) const 🔗
如果指定的 agent 處於暫停狀態,則返回 true。
Vector2 agent_get_position(agent: RID) const 🔗
Returns the position of the specified agent in world space.
float agent_get_radius(agent: RID) const 🔗
Returns the radius of the specified agent.
float agent_get_time_horizon_agents(agent: RID) const 🔗
Returns the minimal amount of time for which the specified agent's velocities that are computed by the simulation are safe with respect to other agents.
float agent_get_time_horizon_obstacles(agent: RID) const 🔗
Returns the minimal amount of time for which the specified agent's velocities that are computed by the simulation are safe with respect to static avoidance obstacles.
Vector2 agent_get_velocity(agent: RID) const 🔗
Returns the velocity of the specified agent.
bool agent_has_avoidance_callback(agent: RID) const 🔗
Return true if the specified agent has an avoidance callback.
bool agent_is_map_changed(agent: RID) const 🔗
Returns true if the map got changed the previous frame.
void agent_set_avoidance_callback(agent: RID, callback: Callable) 🔗
設定在 agent 的每個避障處理步驟之後呼叫的回呼函式 Callable。計算出的 safe_velocity 將在物理計算之前通過訊號發送。
注意:只要代理還在導覽地圖上且未被釋放,建立的回呼函式就會始終獨立於 SceneTree 狀態進行處理。要為某個代理禁用回呼函式的發送,請再次使用一個空的 Callable 來呼叫 agent_set_avoidance_callback()。
void agent_set_avoidance_enabled(agent: RID, enabled: bool) 🔗
如果 enabled 為 true,則指定的 agent 使用避障。
void agent_set_avoidance_layers(agent: RID, layers: int) 🔗
設定該代理的 avoidance_layers 位元遮罩。
void agent_set_avoidance_mask(agent: RID, mask: int) 🔗
設定該代理的 avoidance_mask 位元遮罩。
void agent_set_avoidance_priority(agent: RID, priority: float) 🔗
Set the agent's avoidance_priority with a priority between 0.0 (lowest priority) to 1.0 (highest priority).
The specified agent does not adjust the velocity for other agents that would match the avoidance_mask but have a lower avoidance_priority. This in turn makes the other agents with lower priority adjust their velocities even more to avoid collision with this agent.
void agent_set_map(agent: RID, map: RID) 🔗
將代理放入地圖中。
void agent_set_max_neighbors(agent: RID, count: int) 🔗
設定在導覽中,該代理所考慮的其他代理的最大數量。這個數越大,模擬的執行時間越長。如果這個數太小,則模擬會不安全。
void agent_set_max_speed(agent: RID, max_speed: float) 🔗
設定該代理的最大速度。必須為正數。
void agent_set_neighbor_distance(agent: RID, distance: float) 🔗
設定在導覽中,該代理所考慮的其他代理的最大距離。這個數越大,模擬的執行時間越長。如果這個數太小,則模擬會不安全。
void agent_set_paused(agent: RID, paused: bool) 🔗
If paused is true the specified agent will not be processed. For example, it will not calculate avoidance velocities or receive avoidance callbacks.
void agent_set_position(agent: RID, position: Vector2) 🔗
設定該代理在世界空間中的位置。
void agent_set_radius(agent: RID, radius: float) 🔗
設定該代理的半徑。
void agent_set_time_horizon_agents(agent: RID, time_horizon: float) 🔗
考慮其他代理的前提下,該代理的速度的最短安全時間,這個速度是通過模擬得到的。數值越大,代理回應其他代理的速度就越快,但該代理選擇速度的自由度也就越小。太高的取值會大大降低代理的移動速度。必須為正數。
void agent_set_time_horizon_obstacles(agent: RID, time_horizon: float) 🔗
考慮其他靜態避障障礙物的前提下,該代理的速度的最短安全時間,這個速度是通過仿真得到的。數值越大,代理回應存在的靜態避障障礙物的速度就越快,但該代理選擇速度的自由度也就越小。太高的取值會大大降低代理的移動速度。必須為正數。
void agent_set_velocity(agent: RID, velocity: Vector2) 🔗
將 velocity 設定為指定代理 agent 的新的需求速度。避障模擬會盡可能嘗試滿足這個速度,但為了躲避與其他代理和障礙物的碰撞也會對它進行修改。將代理傳送至新的較遠的位置時,請改用 agent_set_velocity_forced() 重設內部速度狀態。
void agent_set_velocity_forced(agent: RID, velocity: Vector2) 🔗
將指定代理 agent 的避障模擬內部速度替換為 velocity。將代理傳送至新的較遠的位置時,應該在同一影格裡使用這個函式。頻繁呼叫這個函式可能讓代理卡住。
void bake_from_source_geometry_data(navigation_polygon: NavigationPolygon, source_geometry_data: NavigationMeshSourceGeometryData2D, callback: Callable = Callable()) 🔗
使用 source_geometry_data 中提供的資料對 navigation_polygon 進行烘焙。烘焙過程結束後,會呼叫可選的 callback。
void bake_from_source_geometry_data_async(navigation_polygon: NavigationPolygon, source_geometry_data: NavigationMeshSourceGeometryData2D, callback: Callable = Callable()) 🔗
使用 source_geometry_data 中提供的資料對 navigation_polygon 進行烘焙。烘焙過程結束後,會呼叫可選的 callback。
銷毀給定的 RID。
bool get_debug_enabled() const 🔗
如果該 NavigationServer 啟用了除錯,則返回 true。
返回該 NavigationServer 上所有已建立的導覽地圖的 RID。會同時返回已建立的 2D 和 3D 導覽地圖,因為理論上它們之間是沒有區別的。
int get_process_info(process_info: ProcessInfo) const 🔗
Returns information about the current state of the NavigationServer.
bool is_baking_navigation_polygon(navigation_polygon: NavigationPolygon) const 🔗
Returns true when the provided navigation polygon is being baked on a background thread.
在地圖上新建兩個地點之間的連結。
bool link_get_enabled(link: RID) const 🔗
如果指定的 link 處於暫停狀態,則返回 true。
Vector2 link_get_end_position(link: RID) const 🔗
返回連結 link 的結束位置。
float link_get_enter_cost(link: RID) const 🔗
返回 link 連結的進入消耗。
int link_get_iteration_id(link: RID) const 🔗
Returns the current iteration ID of the navigation link. Every time the navigation link changes and synchronizes, the iteration ID increases. An iteration ID of 0 means the navigation link has never synchronized.
Note: The iteration ID will wrap around to 1 after reaching its range limit.
RID link_get_map(link: RID) const 🔗
返回請求的導覽連結 link 目前分配的導覽地圖的 RID。
int link_get_navigation_layers(link: RID) const 🔗
返回 link 的導覽層。
int link_get_owner_id(link: RID) const 🔗
返回管理該連結的物件的 ObjectID。
Vector2 link_get_start_position(link: RID) const 🔗
返回 link 連結的入口位置。
float link_get_travel_cost(link: RID) const 🔗
返回 link 連結的移動消耗。
bool link_is_bidirectional(link: RID) const 🔗
返回該 link 是否能夠雙向通行。
void link_set_bidirectional(link: RID, bidirectional: bool) 🔗
設定該 link 是否能夠雙向通行。
void link_set_enabled(link: RID, enabled: bool) 🔗
如果 enabled 為 true,則指定的 link 使用避障。
void link_set_end_position(link: RID, position: Vector2) 🔗
設定 link 的出口位置。
void link_set_enter_cost(link: RID, enter_cost: float) 🔗
設定 link 的進入消耗 enter_cost。
void link_set_map(link: RID, map: RID) 🔗
設定該連結的導覽地圖 RID。
void link_set_navigation_layers(link: RID, navigation_layers: int) 🔗
設定該連結的導覽層。可以在(使用 map_get_path())進行路徑請求時選擇連結。
void link_set_owner_id(link: RID, owner_id: int) 🔗
設定管理該連結的物件的 ObjectID。
void link_set_start_position(link: RID, position: Vector2) 🔗
設定 link 的入口位置。
void link_set_travel_cost(link: RID, travel_cost: float) 🔗
設定 link 的移動消耗 travel_cost。
建立一張新地圖。
void map_force_update(map: RID) 🔗
已棄用: This method is no longer supported, as it is incompatible with asynchronous updates. It can only be used in a single-threaded context, at your own risk.
This function immediately forces synchronization of the specified navigation map RID. By default navigation maps are only synchronized at the end of each physics frame. This function can be used to immediately (re)calculate all the navigation meshes and region connections of the navigation map. This makes it possible to query a navigation path for a changed map immediately and in the same frame (multiple times if needed).
Due to technical restrictions the current NavigationServer command queue will be flushed. This means all already queued update commands for this physics frame will be executed, even those intended for other maps, regions and agents not part of the specified map. The expensive computation of the navigation meshes and region connections of a map will only be done for the specified map. Other maps will receive the normal synchronization at the end of the physics frame. Should the specified map receive changes after the forced update it will update again as well when the other maps receive their update.
Avoidance processing and dispatch of the safe_velocity signals is unaffected by this function and continues to happen for all maps and agents at the end of the physics frame.
Note: With great power comes great responsibility. This function should only be used by users that really know what they are doing and have a good reason for it. Forcing an immediate update of a navigation map requires locking the NavigationServer and flushing the entire NavigationServer command queue. Not only can this severely impact the performance of a game but it can also introduce bugs if used inappropriately without much foresight.
Array[RID] map_get_agents(map: RID) const 🔗
返回所有與請求的導覽地圖 map 關聯的導覽代理的 RID。
float map_get_cell_size(map: RID) const 🔗
返回地圖的儲存格大小,用於將導覽網格的頂點進行柵格化。
Vector2 map_get_closest_point(map: RID, to_point: Vector2) const 🔗
Returns the navigation mesh surface point closest to the provided to_point on the navigation map.
RID map_get_closest_point_owner(map: RID, to_point: Vector2) const 🔗
Returns the owner region RID for the navigation mesh surface point closest to the provided to_point on the navigation map.
float map_get_edge_connection_margin(map: RID) const 🔗
返回地圖的邊界連接邊距。邊界連接邊距是用於連接兩個地區的距離。
int map_get_iteration_id(map: RID) const 🔗
Returns the current iteration id of the navigation map. Every time the navigation map changes and synchronizes the iteration id increases. An iteration id of 0 means the navigation map has never synchronized.
Note: The iteration id will wrap back to 1 after reaching its range limit.
float map_get_link_connection_radius(map: RID) const 🔗
返回該地圖的連結連接半徑。該距離是任何連結將搜索要連接的導覽網格多邊形的最大範圍。
Array[RID] map_get_links(map: RID) const 🔗
返回目前分配給請求的導覽地圖 map 的所有導覽連結的 RID。
float map_get_merge_rasterizer_cell_scale(map: RID) const 🔗
Returns map's internal merge rasterizer cell scale.
Array[RID] map_get_obstacles(map: RID) const 🔗
返回目前分配給請求的導覽地圖 map 的所有導覽障礙物的 RID。
PackedVector2Array map_get_path(map: RID, origin: Vector2, destination: Vector2, optimize: bool, navigation_layers: int = 1) 🔗
返回從原點到達目的地的導覽路徑。navigation_layers 是被允許在路徑中的所有區塊導覽層的位元遮罩。
Vector2 map_get_random_point(map: RID, navigation_layers: int, uniformly: bool) const 🔗
Returns a random position picked from all map region polygons with matching navigation_layers.
If uniformly is true, all map regions, polygons, and faces are weighted by their surface area (slower).
If uniformly is false, just a random region and a random polygon are picked (faster).
Array[RID] map_get_regions(map: RID) const 🔗
返回目前分配給所請求的導覽 map 的所有導覽區塊的 RID。
bool map_get_use_async_iterations(map: RID) const 🔗
Returns true if the map synchronization uses an async process that runs on a background thread.
bool map_get_use_edge_connections(map: RID) const 🔗
返回是否允許導覽地圖 map 使用邊緣連接與位於導覽地圖邊緣連接邊距範圍內的其他導覽區塊相連接。
bool map_is_active(map: RID) const 🔗
Returns true if the map is active.
void map_set_active(map: RID, active: bool) 🔗
設定地圖的啟動態。
void map_set_cell_size(map: RID, cell_size: float) 🔗
設定用於柵格化導覽網格頂點的地圖儲存格大小。必須與所使用的導覽網格儲存格大小相配對。
void map_set_edge_connection_margin(map: RID, margin: float) 🔗
設定用於焊接相容地區邊界的地圖邊界連接邊距。
void map_set_link_connection_radius(map: RID, radius: float) 🔗
設定該地圖用於連接連結和導覽多邊形的連結連接半徑。
void map_set_merge_rasterizer_cell_scale(map: RID, scale: float) 🔗
Set the map's internal merge rasterizer cell scale used to control merging sensitivity.
void map_set_use_async_iterations(map: RID, enabled: bool) 🔗
If enabled is true the map synchronization uses an async process that runs on a background thread.
void map_set_use_edge_connections(map: RID, enabled: bool) 🔗
設定導覽地圖 map 的邊緣連接使用情況。如果 enabled,則導覽地圖允許導覽區塊使用邊緣連接與位於導覽地圖邊緣連接邊距範圍內的其他導覽區塊相連接。
新建導覽障礙物。
bool obstacle_get_avoidance_enabled(obstacle: RID) const 🔗
如果給定的 obstacle 啟用了避障,則返回 true。
int obstacle_get_avoidance_layers(obstacle: RID) const 🔗
Returns the avoidance_layers bitmask of the specified obstacle.
RID obstacle_get_map(obstacle: RID) const 🔗
返回請求的障礙物 obstacle 目前分配的導覽地圖 RID。
bool obstacle_get_paused(obstacle: RID) const 🔗
如果指定的 obstacle 被暫停,則返回 true。
Vector2 obstacle_get_position(obstacle: RID) const 🔗
Returns the position of the specified obstacle in world space.
float obstacle_get_radius(obstacle: RID) const 🔗
Returns the radius of the specified dynamic obstacle.
Vector2 obstacle_get_velocity(obstacle: RID) const 🔗
Returns the velocity of the specified dynamic obstacle.
PackedVector2Array obstacle_get_vertices(obstacle: RID) const 🔗
Returns the outline vertices for the specified obstacle.
void obstacle_set_avoidance_enabled(obstacle: RID, enabled: bool) 🔗
如果 enabled,則提供的障礙物 obstacle 會影響代理的避障。
void obstacle_set_avoidance_layers(obstacle: RID, layers: int) 🔗
設定障礙物的避障層 avoidance_layers 位元遮罩。
void obstacle_set_map(obstacle: RID, map: RID) 🔗
為障礙物設定導覽地圖 RID。
void obstacle_set_paused(obstacle: RID, paused: bool) 🔗
If paused is true the specified obstacle will not be processed. For example, it will no longer affect avoidance velocities.
void obstacle_set_position(obstacle: RID, position: Vector2) 🔗
設定障礙物在世界空間中的位置。
void obstacle_set_radius(obstacle: RID, radius: float) 🔗
設定動態障礙物的半徑。
void obstacle_set_velocity(obstacle: RID, velocity: Vector2) 🔗
將動態障礙物 obstacle 的速度設定為 velocity。能夠讓其他代理更好地預測該動態障礙物的移動。僅在與障礙物半徑一同使用時有效。
void obstacle_set_vertices(obstacle: RID, vertices: PackedVector2Array) 🔗
設定障礙物的輪廓頂點。如果頂點順時針纏繞,則障礙物會將代理向內部推擠,否則向外推擠。
void parse_source_geometry_data(navigation_polygon: NavigationPolygon, source_geometry_data: NavigationMeshSourceGeometryData2D, root_node: Node, callback: Callable = Callable()) 🔗
根據 navigation_polygon 的屬性解析 SceneTree 中的源幾何體。會使用解析的結果對提供的 source_geometry_data 資源進行更新。後續可以在使用 bake_from_source_geometry_data() 烘焙導覽網格時使用該資源。解析過程完成後,會呼叫可選的 callback。
注意:因為 SceneTree 並不是執行緒安全的,所以這個函式需要在主執行緒執行或使用延遲呼叫。
注意:從 Mesh 資源讀取資料陣列雖然很方便,但會對影格率造成負面影響。這些資料需要從 GPU 獲取,卡住正在處理的 RenderingServer。出於性能考量,請優先使用碰撞形狀或在程式碼中建立完整的資料陣列等方法。
void query_path(parameters: NavigationPathQueryParameters2D, result: NavigationPathQueryResult2D, callback: Callable = Callable()) 🔗
Queries a path in a given navigation map. Start and target position and other parameters are defined through NavigationPathQueryParameters2D. Updates the provided NavigationPathQueryResult2D result object with the path among other results requested by the query. After the process is finished the optional callback will be called.
建立一個新的地區。
Rect2 region_get_bounds(region: RID) const 🔗
Returns the axis-aligned rectangle for the region's transformed navigation mesh.
Vector2 region_get_closest_point(region: RID, to_point: Vector2) const 🔗
Returns the navigation mesh surface point closest to the provided to_point on the navigation region.
Vector2 region_get_connection_pathway_end(region: RID, connection: int) const 🔗
返回連接門的終點。connection 是一個索引,介於 0 和 region_get_connections_count() 的返回值之間。
Vector2 region_get_connection_pathway_start(region: RID, connection: int) const 🔗
返回連接門的起點。connection 是一個索引,介於 0 和 region_get_connections_count() 的返回值之間。
int region_get_connections_count(region: RID) const 🔗
返回 region 地區與其他地區在地圖上有多少連接。
bool region_get_enabled(region: RID) const 🔗
Returns true if the specified region is enabled.
float region_get_enter_cost(region: RID) const 🔗
返回 region 地區的進入消耗。
int region_get_iteration_id(region: RID) const 🔗
Returns the current iteration ID of the navigation region. Every time the navigation region changes and synchronizes, the iteration ID increases. An iteration ID of 0 means the navigation region has never synchronized.
Note: The iteration ID will wrap around to 1 after reaching its range limit.
RID region_get_map(region: RID) const 🔗
返回請求的 region 地區所關聯的導覽地圖的 RID。
int region_get_navigation_layers(region: RID) const 🔗
返回該地區的導覽層。
int region_get_owner_id(region: RID) const 🔗
返回管理該地區物件的 ObjectID。
Vector2 region_get_random_point(region: RID, navigation_layers: int, uniformly: bool) const 🔗
Returns a random position picked from all region polygons with matching navigation_layers.
If uniformly is true, all region polygons and faces are weighted by their surface area (slower).
If uniformly is false, just a random polygon and face is picked (faster).
Transform2D region_get_transform(region: RID) const 🔗
Returns the global transformation of this region.
float region_get_travel_cost(region: RID) const 🔗
返回 region 地區的移動消耗。
bool region_get_use_async_iterations(region: RID) const 🔗
Returns true if the region uses an async synchronization process that runs on a background thread.
bool region_get_use_edge_connections(region: RID) const 🔗
返回導覽區塊 region 是否被設定為使用邊緣連接與位於導覽地圖邊緣連接邊距範圍內的其他導覽區塊相連接。
bool region_owns_point(region: RID, point: Vector2) const 🔗
如果提供的世界空間中的 point 目前由提供的導覽區塊 region 擁有,則返回 true。在這裡的本文中,“擁有”意味著與來自其他導覽區塊的所有其他導覽網格相比,該區塊的導覽網格多邊形面中有一個距離該點最近的可能位置,這些其他導覽區塊也已在提供的區塊的導覽地圖上註冊。
如果有多個導覽網格存在符合條件的位置並且距離相等,那麼其多邊形先被處理的導覽區塊將贏得所有權。多邊形的處理順序與導覽區塊在 NavigationServer 上的註冊順序一致。
注意:如果來自不同導覽區塊的導覽網格存在重疊(通常應當避免),可能會得到預料之外的結果。
void region_set_enabled(region: RID, enabled: bool) 🔗
如果 enabled 為 true,則指定的 region 使用避障。
void region_set_enter_cost(region: RID, enter_cost: float) 🔗
設定 region 地區的進入消耗 enter_cost。
void region_set_map(region: RID, map: RID) 🔗
設定該地區的地圖。
void region_set_navigation_layers(region: RID, navigation_layers: int) 🔗
設定地區的導覽層。能夠在路徑請求中選擇地區(使用 map_get_path() 時)。
void region_set_navigation_polygon(region: RID, navigation_polygon: NavigationPolygon) 🔗
設定該地區的導覽多邊形 navigation_polygon。
void region_set_owner_id(region: RID, owner_id: int) 🔗
設定管理該地區物件的 ObjectID。
void region_set_transform(region: RID, transform: Transform2D) 🔗
設定該地區的全域變換。
void region_set_travel_cost(region: RID, travel_cost: float) 🔗
設定 region 地區的移動消耗 travel_cost。
void region_set_use_async_iterations(region: RID, enabled: bool) 🔗
If enabled is true the region uses an async synchronization process that runs on a background thread.
void region_set_use_edge_connections(region: RID, enabled: bool) 🔗
如果 enabled,導覽區塊 region 將使用邊緣連接來與位於導覽地圖邊緣連接邊距範圍內的其他導覽區塊相連接。
void set_active(active: bool) 🔗
控制這個伺服器是否啟動。
void set_debug_enabled(enabled: bool) 🔗
如果為 true,則該 NavigationServer 啟用了除錯模式。
PackedVector2Array simplify_path(path: PackedVector2Array, epsilon: float) 🔗
Returns a simplified version of path with less critical path points removed. The simplification amount is in worlds units and controlled by epsilon. The simplification uses a variant of Ramer-Douglas-Peucker algorithm for curve point decimation.
Path simplification can be helpful to mitigate various path following issues that can arise with certain agent types and script behaviors. E.g. "steering" agents or avoidance in "open fields".
RID source_geometry_parser_create() 🔗
Creates a new source geometry parser. If a Callable is set for the parser with source_geometry_parser_set_callback() the callback will be called for every single node that gets parsed whenever parse_source_geometry_data() is used.
void source_geometry_parser_set_callback(parser: RID, callback: Callable) 🔗
Sets the callback Callable for the specific source geometry parser. The Callable will receive a call with the following parameters:
navigation_mesh- The NavigationPolygon reference used to define the parse settings. Do NOT edit or add directly to the navigation mesh.source_geometry_data- The NavigationMeshSourceGeometryData2D reference. Add custom source geometry for navigation mesh baking to this object.node- The Node that is parsed.