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...
NavigationRegion2D
實驗性: This class may be changed or removed in future versions.
繼承: Node2D < CanvasItem < Node < Object
可達的 2D 地區,NavigationAgent2D 能夠將其用於尋路。
說明
可達的 2D 地區,基於 NavigationPolygon,NavigationAgent2D 能夠將其用於尋路。
兩個地區如果存在相近的邊就可以互相連接。連接兩條邊所需的頂點最小間距可以通過 NavigationServer2D.map_set_edge_connection_margin() 設定。
注意:兩個地區存在重疊部分並不足以讓它們相連。必須有相近的邊。
從一個地區進入另一個地區的尋路成本可以使用 enter_cost 控制。
注意:起點位於該地區時,這個值不計入路徑成本。
在該地區中行進的尋路成本可以使用乘數 travel_cost 控制。
注意:該節點會對這些屬性進行快取,因此,你在 NavigationServer2D 中對底層的地區 RID 進行的修改不會在該節點的屬性中。
教學
屬性
|
||
|
||
|
||
|
||
|
方法
void |
bake_navigation_polygon(on_thread: bool = true) |
get_bounds() const |
|
get_navigation_layer_value(layer_number: int) const |
|
get_navigation_map() const |
|
get_region_rid() const |
|
get_rid() const |
|
is_baking() const |
|
void |
set_navigation_layer_value(layer_number: int, value: bool) |
void |
set_navigation_map(navigation_map: RID) |
訊號
bake_finished() 🔗
導覽網格烘焙操作完成時發出通知。
navigation_polygon_changed() 🔗
當替換使用的導覽多邊形或提交目前導覽多邊形內部的變更時發出。
屬性說明
決定該 NavigationRegion2D 是啟用還是禁用。
When pathfinding enters this region's navigation mesh from another regions navigation mesh the enter_cost value is added to the path distance for determining the shortest path.
確定該區塊所屬的所有導覽層的位欄位。當使用 NavigationServer2D.map_get_path() 請求一個路徑時,可以檢查這些導覽層。
NavigationPolygon navigation_polygon 🔗
void set_navigation_polygon(value: NavigationPolygon)
NavigationPolygon get_navigation_polygon()
使用的 NavigationPolygon 資源。
When pathfinding moves inside this region's navigation mesh the traveled distances are multiplied with travel_cost for determining the shortest path.
bool use_edge_connections = true 🔗
如果啟用,導覽區塊將使用邊緣連接來與位於導覽地圖連接邊距範圍內的其他導覽區塊相連接。
方法說明
void bake_navigation_polygon(on_thread: bool = true) 🔗
烘焙 NavigationPolygon。如果 on_thread 設定為 true(預設),則烘焙將在單獨的線程上完成。
Returns the axis-aligned rectangle for the region's transformed navigation mesh.
bool get_navigation_layer_value(layer_number: int) const 🔗
返回 navigation_layers 位元遮罩中指定的層是否啟用,給定的 layer_number 應在 1 和 32 之間。
RID get_navigation_map() const 🔗
設定該連結的導覽地圖 RID。
已棄用: Use get_rid() instead.
Returns the RID of this region on the NavigationServer2D.
返回 NavigationServer2D 上該區塊的 RID。結合 NavigationServer2D.map_get_closest_point_owner() 可用於識別合併導覽地圖上離某點最近的 NavigationRegion2D。
Returns true when the NavigationPolygon is being baked on a background thread.
void set_navigation_layer_value(layer_number: int, value: bool) 🔗
根據 value,啟用或禁用 navigation_layers 位元遮罩中指定的層,給定的 layer_number 應在 1 和 32 之間。
void set_navigation_map(navigation_map: RID) 🔗
設定該區域應使用的導覽地圖的RID。預設情況下,該區域將自動加入World2D預設導覽地圖,因此僅需要此函式來覆寫預設地圖。 “,““,“,“錯誤的”,””,”,”
doc/classes/NavigationRegion2D.xml"