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...
NavigationServer3D
實驗性: This class may be changed or removed in future versions.
繼承: Object
用於存取低階 3D 導覽的伺服器介面。
說明
NavigationServer3D is the server that handles navigation maps, regions, and agents. It does not handle A* navigation from AStar3D.
Maps are divided into regions, which are composed of navigation meshes. Together, they define the navigable areas in the 3D world.
Note: Most NavigationServer3D 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
常數,用於取得活動導航障礙物的數量。
方法說明
建立代理。
bool agent_get_avoidance_enabled(agent: RID) const 🔗
如果指定代理 agent 啟用了避障,則返回 true。
int agent_get_avoidance_layers(agent: RID) const 🔗
回傳指定 agent 的 avoidance_layers 位元遮罩。
int agent_get_avoidance_mask(agent: RID) const 🔗
回傳指定 agent 的 avoidance_mask 位元遮罩。
float agent_get_avoidance_priority(agent: RID) const 🔗
回傳指定 agent 的 avoidance_priority。
float agent_get_height(agent: RID) const 🔗
回傳指定的 agent 的 height。
RID agent_get_map(agent: RID) const 🔗
返回請求 agent 目前分配到的導覽地圖 RID。
int agent_get_max_neighbors(agent: RID) const 🔗
回傳在導航中指定的 agent 考慮的其他代理的最大數量。
float agent_get_max_speed(agent: RID) const 🔗
回傳指定 agent 的最大速度。
float agent_get_neighbor_distance(agent: RID) const 🔗
回傳在導航中到指定 agent 考慮的其他代理的最大距離。
bool agent_get_paused(agent: RID) const 🔗
如果指定的 agent 處於暫停狀態,則返回 true。
Vector3 agent_get_position(agent: RID) const 🔗
回傳在世界空間中指定的 agent 的位置。
float agent_get_radius(agent: RID) const 🔗
回傳指定 agent 的半徑。
float agent_get_time_horizon_agents(agent: RID) const 🔗
回傳指定的 agent 如果持續使用由仿真過程計算出的速度移動,能夠不與其他代理髮生碰撞的最短時間。
float agent_get_time_horizon_obstacles(agent: RID) const 🔗
回傳指定的 agent 如果持續使用由仿真過程計算出的速度移動,能夠不與靜態障礙物發生碰撞的最短時間。
bool agent_get_use_3d_avoidance(agent: RID) const 🔗
如果指定代理 agent 使用 3D 空間 Vector3(x,y,z) 的避障而不是水平 2D Vector2(x,y) / Vector3(x,0.0,z) 避障,則返回 true。
Vector3 agent_get_velocity(agent: RID) const 🔗
回傳指定 agent 的速度。
bool agent_has_avoidance_callback(agent: RID) const 🔗
如果指定的 agent 有避障回呼,則回傳 true。
bool agent_is_map_changed(agent: RID) const 🔗
如果地圖在上一影格發生了變化,則回傳 true。
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) 🔗
設定該代理的 avoidance_priority,優先級 priority 在 0.0(最低優先級)到 1.0(最高優先級)之間。
agent 指定的代理不會針對 avoidance_mask 存在匹配但 avoidance_priority 更低的代理調整速度。相應地,優先級更低的代理則會對其速度進行更大的調整,從而避免與這個代理髮生碰撞。
void agent_set_height(agent: RID, height: float) 🔗
更新指定代理 agent 的高度 height。
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) 🔗
如果 paused 為 true,則不會處理 agent 所指定的代理,例如不會計算避障速度,也不會收到避障回呼。
void agent_set_position(agent: RID, position: Vector3) 🔗
設定該代理在世界空間中的位置。
void agent_set_radius(agent: RID, radius: float) 🔗
設定該代理的半徑。
void agent_set_time_horizon_agents(agent: RID, time_horizon: float) 🔗
The minimal amount of time for which the agent's velocities that are computed by the simulation are safe with respect to other agents. The larger this number, the sooner this agent will respond to the presence of other agents, but the less freedom this agent has in choosing its velocities. A too high value will slow down agent movement considerably. Must be positive.
void agent_set_time_horizon_obstacles(agent: RID, time_horizon: float) 🔗
The minimal amount of time for which the agent's velocities that are computed by the simulation are safe with respect to static avoidance obstacles. The larger this number, the sooner this agent will respond to the presence of static avoidance obstacles, but the less freedom this agent has in choosing its velocities. A too high value will slow down agent movement considerably. Must be positive.
void agent_set_use_3d_avoidance(agent: RID, enabled: bool) 🔗
Sets if the agent uses the 2D avoidance or the 3D avoidance while avoidance is enabled.
If true the agent calculates avoidance velocities in 3D for the XYZ axes, e.g. for games that take place in the air, underwater, or space. The 3D agent only avoids other 3D avoidance agents. The 3D agent only reacts to radius based avoidance obstacles. The 3D agent ignores any vertices based obstacles. The 3D agent only avoids other 3D agents.
If false the agent calculates avoidance velocities in 2D along the xz-axes ignoring the y-axis. The 2D agent only avoids other 2D avoidance agents. The 2D agent reacts to radius avoidance obstacles. The 2D agent reacts to vertex based avoidance obstacles. The 2D agent only avoids other 2D agents. 2D agents will ignore other 2D agents or obstacles that are below their current position or above their current position including the agent's height in 2D avoidance.
void agent_set_velocity(agent: RID, velocity: Vector3) 🔗
Sets velocity as the new wanted velocity for the specified agent. The avoidance simulation will try to achieve this velocity if possible, but will adjust it to avoid colliding with other agents and obstacles. When an agent is teleported to a new position far away, use agent_set_velocity_forced() instead to reset the internal velocity state.
void agent_set_velocity_forced(agent: RID, velocity: Vector3) 🔗
將指定代理 agent 的避障模擬內部速度替換為 velocity。將代理傳送至新的位置時,應該在同一影格裡使用這個函式。頻繁呼叫這個函式可能讓代理卡住。
void bake_from_source_geometry_data(navigation_mesh: NavigationMesh, source_geometry_data: NavigationMeshSourceGeometryData3D, callback: Callable = Callable()) 🔗
使用 source_geometry_data 中提供的資料對 navigation_mesh 進行烘焙。烘焙過程結束後,會呼叫可選的 callback。
void bake_from_source_geometry_data_async(navigation_mesh: NavigationMesh, source_geometry_data: NavigationMeshSourceGeometryData3D, callback: Callable = Callable()) 🔗
使用 source_geometry_data 中提供的資料對 navigation_mesh 進行烘焙。烘焙過程結束後,會呼叫可選的 callback。
銷毀給定的 RID。
bool get_debug_enabled() const 🔗
如果該 NavigationServer 啟用了除錯,則返回 true。
返回該 NavigationServer 上所有已建立的導覽地圖的 RID。會同時返回已建立的 2D 和 3D 導覽地圖,因為理論上它們之間是沒有區別的。
int get_process_info(process_info: ProcessInfo) const 🔗
回傳有關 NavigationServer 目前狀態的資訊。
bool is_baking_navigation_mesh(navigation_mesh: NavigationMesh) const 🔗
當提供的導覽網格正在後台執行緒上烘焙時回傳 true。
在地圖上新建兩個地點之間的連結。
bool link_get_enabled(link: RID) const 🔗
如果指定的 link 處於暫停狀態,則返回 true。
Vector3 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 🔗
回傳導航連結的目前迭代 ID。導航連結發生更改並同步時都會增加迭代 ID。迭代 ID 為 0 表示導航連結從未進行過同步。
注意:迭代 ID 超過取值範圍後會繞回 1。
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。
Vector3 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: Vector3) 🔗
設定 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) 🔗
Sets the given link's navigation layers to navigation_layers. This allows selecting links from a path request (when using map_get_path()).
void link_set_owner_id(link: RID, owner_id: int) 🔗
設定管理該連結的物件的 ObjectID。
void link_set_start_position(link: RID, position: Vector3) 🔗
設定 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 🔗
Returns all navigation agent RIDs that are currently assigned to the requested navigation map.
float map_get_cell_height(map: RID) const 🔗
返回在 Y 軸上柵格化導覽網格頂點所使用的地圖儲存格高度。
float map_get_cell_size(map: RID) const 🔗
返回在 XZ 平面上柵格化導覽網格頂點所使用的地圖儲存格大小。
Vector3 map_get_closest_point(map: RID, to_point: Vector3) const 🔗
回傳導航地圖 map 中,導覽網格表面上與給定的 to_point 距離最近的點。
Vector3 map_get_closest_point_normal(map: RID, to_point: Vector3) const 🔗
回傳導航地圖 map 上與給定點 to_point 最接近的導覽網格表面法線。
RID map_get_closest_point_owner(map: RID, to_point: Vector3) const 🔗
回傳導航地圖 map 中,導覽網格表面上與給定的 to_point 距離最近的點對應的所有者區塊 RID。
Vector3 map_get_closest_point_to_segment(map: RID, start: Vector3, end: Vector3, use_collision: bool = false) const 🔗
回傳導航地圖 map 上與給定起點 start 和終點 end 構成的線段最接近的導覽網格表面點。
如果 use_collision 為 true,則只有線上段與該導覽網格表面相交時才算最接近的點。
float map_get_edge_connection_margin(map: RID) const 🔗
返回地圖的邊界連接邊距。這是讓兩個不同地區的邊界相連所需的最小頂點距離。
int map_get_iteration_id(map: RID) const 🔗
返回目前導航地圖的迭代 ID。每當導航地圖發生改變並進行同步時,這個迭代 id 就會增加。如果迭代id 為 0,則表示該導航地圖從未進行過同步。
注意: 當迭代 ID 達到其數值範圍的上限時,會重新繞回 1。
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 the map's internal merge rasterizer cell scale.
Array[RID] map_get_obstacles(map: RID) const 🔗
返回目前分配給請求的導覽地圖 map 的所有導覽障礙物的 RID。
PackedVector3Array map_get_path(map: RID, origin: Vector3, destination: Vector3, optimize: bool, navigation_layers: int = 1) 🔗
返回從原點到達目的地的導覽路徑。navigation_layers 是被允許在路徑中的所有區塊導覽層的位元遮罩。
Vector3 map_get_random_point(map: RID, navigation_layers: int, uniformly: bool) const 🔗
回傳與 navigation_layers 匹配的所有地圖區塊多邊形中隨機挑選的位置。
如果 uniformly 為 true,則所有地圖區塊、多邊形、面的權重都會根據對應表面調整權重(較慢)。
如果 uniformly 為 false,則只會簡單地隨機挑選一個區塊和一個多邊形(較快)。
Array[RID] map_get_regions(map: RID) const 🔗
Returns all navigation region RIDs that are currently assigned to the requested navigation map.
Vector3 map_get_up(map: RID) const 🔗
返回地圖的上方向。
bool map_get_use_async_iterations(map: RID) const 🔗
如果地圖 map 的同步使用後台執行緒非同步處理,則回傳 true。
bool map_get_use_edge_connections(map: RID) const 🔗
如果導航地圖 map 允許導航區塊使用邊緣連接與位於導航地圖邊緣連接邊距範圍內的其他導航區塊相連接,則回傳 true。
bool map_is_active(map: RID) const 🔗
如果地圖處於活動狀態,則回傳 true。
void map_set_active(map: RID, active: bool) 🔗
設定地圖的啟動態。
void map_set_cell_height(map: RID, cell_height: float) 🔗
設定在 Y 軸上柵格化導覽網格頂點所使用的地圖儲存格高度。必須與所使用的導覽網格的儲存格高度相配對。
void map_set_cell_size(map: RID, cell_size: float) 🔗
設定在 XZ 平面上柵格化導覽網格頂點所使用的地圖儲存格大小。必須與所使用的導覽網格的儲存格大小相配對。
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) 🔗
設定地圖的內部合併柵格化器的單元格縮放,用於控制合併的敏感度。
void map_set_up(map: RID, up: Vector3) 🔗
設定地圖的上方向。
void map_set_use_async_iterations(map: RID, enabled: bool) 🔗
如果 enabled 為 true,則地圖 map 的同步使用後台執行緒非同步處理。
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 🔗
回傳指定 obstacle 的 avoidance_layers 位元遮罩。
float obstacle_get_height(obstacle: RID) const 🔗
回傳指定 obstacle 的 height。
RID obstacle_get_map(obstacle: RID) const 🔗
返回請求的障礙物 obstacle 目前分配的導覽地圖 RID。
bool obstacle_get_paused(obstacle: RID) const 🔗
如果指定的 obstacle 被暫停,則返回 true。
Vector3 obstacle_get_position(obstacle: RID) const 🔗
回傳在世界空間中指定的 obstacle 的位置。
float obstacle_get_radius(obstacle: RID) const 🔗
回傳指定的動態 obstacle 的半徑。
bool obstacle_get_use_3d_avoidance(obstacle: RID) const 🔗
如果提供的 obstacle 使用 3D 空間的 Vector3(x,y,z),不使用水平 2D Vector2(x,y) / Vector3(x,0.0,z),則返回 true。
Vector3 obstacle_get_velocity(obstacle: RID) const 🔗
回傳指定的動態 obstacle 的速度。
PackedVector3Array obstacle_get_vertices(obstacle: RID) const 🔗
回傳指定的 obstacle 的輪廓頂點。
void obstacle_set_avoidance_enabled(obstacle: RID, enabled: bool) 🔗
如果 enabled,則提供的障礙物 obstacle 會影響代理的避障。
void obstacle_set_avoidance_layers(obstacle: RID, layers: int) 🔗
Sets the given obstacle's avoidance layers to layers.
void obstacle_set_height(obstacle: RID, height: float) 🔗
設定 obstacle 的高度 height。3D 代理會忽略位於其上方和下方的障礙物,使用 2D 避障。
void obstacle_set_map(obstacle: RID, map: RID) 🔗
將 obstacle 分配給導覽地圖。
void obstacle_set_paused(obstacle: RID, paused: bool) 🔗
如果 paused 為 true,則不會處理 obstacle 所指定的障礙物,例如不會影響避障速度。
void obstacle_set_position(obstacle: RID, position: Vector3) 🔗
為 obstacle 更新世界空間中的位置 position。
void obstacle_set_radius(obstacle: RID, radius: float) 🔗
設定動態障礙物的半徑。
void obstacle_set_use_3d_avoidance(obstacle: RID, enabled: bool) 🔗
設定 obstacle 在啟用避障時使用 2D 避障還是 3D 避障。
void obstacle_set_velocity(obstacle: RID, velocity: Vector3) 🔗
將動態障礙物 obstacle 的速度設定為 velocity。能夠讓其他代理更好地預測該動態障礙物的移動。僅在與障礙物半徑一同使用時有效。
void obstacle_set_vertices(obstacle: RID, vertices: PackedVector3Array) 🔗
設定障礙物的輪廓頂點。如果頂點順時針纏繞,則障礙物會將代理向內部推擠,否則向外推擠。
void parse_source_geometry_data(navigation_mesh: NavigationMesh, source_geometry_data: NavigationMeshSourceGeometryData3D, root_node: Node, callback: Callable = Callable()) 🔗
根據 navigation_mesh 的屬性解析 SceneTree 中的源幾何體。會使用解析的結果對提供的 source_geometry_data 資源進行更新。後續可以在使用 bake_from_source_geometry_data() 烘焙導覽網格時使用該資源。解析過程完成後,會呼叫可選的 callback。
注意:因為 SceneTree 並不是執行緒安全的,所以這個函式需要在主執行緒執行或使用延遲呼叫。
注意:從 Mesh 資源讀取資料陣列雖然很方便,但會對影格率造成負面影響。這些資料需要從 GPU 取得,卡住正在處理的 RenderingServer。出於效能考量,請優先使用碰撞形狀或在程式碼中建立完整的資料陣列等方法。
void query_path(parameters: NavigationPathQueryParameters3D, result: NavigationPathQueryResult3D, callback: Callable = Callable()) 🔗
在給定的導航地圖中查詢路徑。起點、目標點以及其他參數通過 NavigationPathQueryParameters3D 定義。會更新所提供的 NavigationPathQueryResult3D 結果物件中的路徑以及其他查詢中請求的結果。處理完成後會呼叫可選的回呼 callback。
void region_bake_navigation_mesh(navigation_mesh: NavigationMesh, root_node: Node) 🔗
已棄用: This method is deprecated due to core threading changes. To upgrade existing code, first create a NavigationMeshSourceGeometryData3D resource. Use this resource with parse_source_geometry_data() to parse the SceneTree for nodes that should contribute to the navigation mesh baking. The SceneTree parsing needs to happen on the main thread. After the parsing is finished use the resource with bake_from_source_geometry_data() to bake a navigation mesh.
烘焙 navigation_mesh,烘焙的來源幾何體從 root_node 開始收集。
建立一個新的地區。
AABB region_get_bounds(region: RID) const 🔗
回傳區塊 region 變換後的導覽網格所對應的軸對齊邊界框。
Vector3 region_get_closest_point(region: RID, to_point: Vector3) const 🔗
回傳導航區塊 region 上與給定點 to_point 最接近的導覽網格表面點。
Vector3 region_get_closest_point_normal(region: RID, to_point: Vector3) const 🔗
回傳導航區塊 region 上與給定點 to_point 最接近的導覽網格表面法線。
Vector3 region_get_closest_point_to_segment(region: RID, start: Vector3, end: Vector3, use_collision: bool = false) const 🔗
回傳導航區塊 region 上與給定起點 start 和終點 end 構成的線段最接近的導覽網格表面點。
如果 use_collision 為 true,則只有線上段與該導覽網格表面相交時才算最接近的點。
Vector3 region_get_connection_pathway_end(region: RID, connection: int) const 🔗
返回連接門的終點。connection 是一個索引,介於 0 和 region_get_connections_count() 的返回值之間。
Vector3 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 🔗
如果指定的 region 已啟用,則回傳 true。
float region_get_enter_cost(region: RID) const 🔗
返回 region 地區的進入消耗。
int region_get_iteration_id(region: RID) const 🔗
回傳導航區塊的目前迭代 ID。導航區塊發生更改並同步時都會增加迭代 ID。迭代 ID 為 0 表示導航區塊從未進行過同步。
注意:迭代 ID 超過取值範圍後會繞回 1。
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。
Vector3 region_get_random_point(region: RID, navigation_layers: int, uniformly: bool) const 🔗
回傳與 navigation_layers 匹配的所有區塊多邊形中隨機挑選的位置。
如果 uniformly 為 true,則所有區塊多邊形和面的權重都會根據對應表面調整權重(較慢)。
如果 uniformly 為 false,則只會簡單地隨機挑選一個多邊形和一個面(較快)。
Transform3D region_get_transform(region: RID) const 🔗
回傳該 region 的全域變換。
float region_get_travel_cost(region: RID) const 🔗
返回 region 地區的移動消耗。
bool region_get_use_async_iterations(region: RID) const 🔗
如果區塊 region 的同步使用後台執行緒非同步處理,則回傳 true。
bool region_get_use_edge_connections(region: RID) const 🔗
如果導航區塊 region 被設定為使用邊緣連接與位於導航地圖邊緣連接邊距範圍內的其他導航區塊相連接,則回傳 true。
bool region_owns_point(region: RID, point: Vector3) 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_mesh(region: RID, navigation_mesh: NavigationMesh) 🔗
設定該地圖的導覽網格。
void region_set_owner_id(region: RID, owner_id: int) 🔗
設定管理該地區物件的 ObjectID。
void region_set_transform(region: RID, transform: Transform3D) 🔗
設定該地區的全域變換。
void region_set_travel_cost(region: RID, travel_cost: float) 🔗
設定 region 地區的移動消耗 travel_cost。
void region_set_use_async_iterations(region: RID, enabled: bool) 🔗
如果 enabled 為 true,則區塊 region 的同步使用後台執行緒非同步處理。
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 啟用了除錯模式。
PackedVector3Array simplify_path(path: PackedVector3Array, epsilon: float) 🔗
Returns a simplified version of path with less critical path points removed. The simplification amount is in world 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() 🔗
建立一個新的源幾何解析器。如果使用 source_geometry_parser_set_callback() 為解析器設定了 Callable,則每當使用 parse_source_geometry_data() 時,都會為每個解析的節點呼叫回呼。
void source_geometry_parser_set_callback(parser: RID, callback: Callable) 🔗
為指定的源幾何體 parser(解析器)設定 callback Callable。該 Callable 在呼叫時會接收以下參數:
navigation_mesh - 用於定義解析設定的 NavigationPolygon 參照。請勿直接編輯或向其新增內容。
source_geometry_data - NavigationMeshSourceGeometryData2D 參照。請將用於烘焙導覽網格的自訂源幾何體新增到這個物件中。
node - 目前正在被解析的 Node(節點)。