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...
NavigationMesh
實驗性: This class may be changed or removed in future versions.
繼承: Resource < RefCounted < Object
用於定義可達區域和障礙物的導覽網格。
說明
導覽網格是多邊形的集合,用於定義環境中的哪些區域是可以穿越的,説明代理在複雜的空間中尋路。
教學
屬性
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
方法
void |
add_polygon(polygon: PackedInt32Array) |
void |
clear() |
void |
|
void |
create_from_mesh(mesh: Mesh) |
get_collision_mask_value(layer_number: int) const |
|
get_polygon(idx: int) |
|
get_polygon_count() const |
|
get_vertices() const |
|
void |
set_collision_mask_value(layer_number: int, value: bool) |
void |
set_vertices(vertices: PackedVector3Array) |
列舉
enum SamplePartitionType: 🔗
SamplePartitionType SAMPLE_PARTITION_WATERSHED = 0
分水嶺分區。如果你預先計算導覽網格,通常是最佳選擇,如果你有大的開放區域,請使用它。
SamplePartitionType SAMPLE_PARTITION_MONOTONE = 1
單調分區。如果你想要快速生成導覽網格,請使用此選項。
SamplePartitionType SAMPLE_PARTITION_LAYERS = 2
層分區。用於具有中小型圖塊的平鋪導覽網格的不錯選擇。
SamplePartitionType SAMPLE_PARTITION_MAX = 3
代表 SamplePartitionType 列舉的大小。
enum ParsedGeometryType: 🔗
ParsedGeometryType PARSED_GEOMETRY_MESH_INSTANCES = 0
將網格實例解析為幾何體。包括 MeshInstance3D、CSGShape3D、GridMap 等節點。
ParsedGeometryType PARSED_GEOMETRY_STATIC_COLLIDERS = 1
將 StaticBody3D 碰撞器解析為幾何體。碰撞器應在由 geometry_collision_mask 指定的層中。
ParsedGeometryType PARSED_GEOMETRY_BOTH = 2
PARSED_GEOMETRY_MESH_INSTANCES 和 PARSED_GEOMETRY_STATIC_COLLIDERS.
ParsedGeometryType PARSED_GEOMETRY_MAX = 3
代表 ParsedGeometryType 列舉的大小。
enum SourceGeometryMode: 🔗
SourceGeometryMode SOURCE_GEOMETRY_ROOT_NODE_CHILDREN = 0
在根節點的子節點中遞迴掃描幾何體。
SourceGeometryMode SOURCE_GEOMETRY_GROUPS_WITH_CHILDREN = 1
以遞迴方式掃描組中的節點及其子節點以獲取幾何圖形。該組由 geometry_source_group_name 指定。
SourceGeometryMode SOURCE_GEOMETRY_GROUPS_EXPLICIT = 2
使用一個組中的節點進行幾何運算。該組由 geometry_source_group_name 指定。
SourceGeometryMode SOURCE_GEOMETRY_MAX = 3
代表 SourceGeometryMode 列舉的大小。
屬性說明
地板到天花板的最小高度,仍然允許被認為是可行走的地板。
注意:烘焙時,這個值會向上取整到最接近的 cell_height 的倍數。
float agent_max_climb = 0.25 🔗
被認為仍可穿越的最小牆壁高度。
注意:烘焙時,該值將向下四捨五入到最接近的 cell_height 的倍數。
float agent_max_slope = 45.0 🔗
認為可行走的最大坡度,單位是度。
The distance to erode/shrink the walkable area of the heightfield away from obstructions.
Note: While baking, this value will be rounded up to the nearest multiple of cell_size.
Note: The radius must be equal or higher than 0.0. If the radius is 0.0, it won't be possible to fix invalid outline overlaps and other precision errors during the baking process. As a result, some obstacles may be excluded incorrectly from the final navigation mesh, or may delete the navigation mesh's polygons.
The size of the non-navigable border around the bake bounding area.
In conjunction with the filter_baking_aabb and a edge_max_error value at 1.0 or below the border size can be used to bake tile aligned navigation meshes without the tile edges being shrunk by agent_radius.
Note: If this value is not 0.0, it will be rounded up to the nearest multiple of cell_size during baking.
儲存格高度,用於將導覽網格的頂點在 Y 軸上進行柵格化。必須與導覽地圖的儲存格高度配對。
儲存格大小,用於將導覽網格的頂點在 XZ 平面上進行柵格化。必須與導覽地圖的單元格大小配對。
float detail_sample_distance = 6.0 🔗
生成細分網格時使用的取樣距離,以儲存格為單位。
float detail_sample_max_error = 1.0 🔗
細節網格表面應偏離高度場的最大距離,以儲存格為單位。
簡化輪廓的邊界邊緣偏離原始輪廓的最大距離。
沿網格邊界的輪廓的最大允許長度。
注意:烘焙時,這個值會向上取整到最接近的 cell_size 的倍數。
AABB filter_baking_aabb = AABB(0, 0, 0, 0, 0, 0) 🔗
如果烘焙 AABB 存在體積,對該導覽網格的烘焙會被限制在其內部區域中。
Vector3 filter_baking_aabb_offset = Vector3(0, 0, 0) 🔗
套用於 filter_baking_aabb AABB 的位置偏移量。
bool filter_ledge_spans = false 🔗
如果為 true,則標記邊緣間的跨度為不可行走。
bool filter_low_hanging_obstacles = false 🔗
如果為 true,如果它們的最大值在可行走鄰域的 agent_max_climb 內,則將不可行走範圍標記為可行走。
bool filter_walkable_low_height_spans = false 🔗
如果為 true,如果跨度上方的間隙小於 agent_height,則將可行走範圍標記為不可行走。
int geometry_collision_mask = 4294967295 🔗
用於掃描靜態碰撞的實體層。
僅在 geometry_parsed_geometry_type 是 PARSED_GEOMETRY_STATIC_COLLIDERS 或 PARSED_GEOMETRY_BOTH 時才使用。
ParsedGeometryType geometry_parsed_geometry_type = 2 🔗
void set_parsed_geometry_type(value: ParsedGeometryType)
ParsedGeometryType get_parsed_geometry_type()
Determines which type of nodes will be parsed as geometry.
SourceGeometryMode geometry_source_geometry_mode = 0 🔗
void set_source_geometry_mode(value: SourceGeometryMode)
SourceGeometryMode get_source_geometry_mode()
The source of the geometry used when baking.
StringName geometry_source_group_name = &"navigation_mesh_source_group" 🔗
void set_source_group_name(value: StringName)
StringName get_source_group_name()
群組的名稱,會在該群組中掃描幾何體。
只有當 geometry_source_geometry_mode 是 SOURCE_GEOMETRY_GROUPS_WITH_CHILDREN 或 SOURCE_GEOMETRY_GROUPS_EXPLICIT 時才使用。
float region_merge_size = 20.0 🔗
如果可能的話,任何小於這個尺寸的區域將與較大的區域合併。
注意:這個值將被平方來計算儲存格的數量。例如,值為 20 時將把儲存格的數量設為 400。
區域被建立所需的最小尺寸。
注意:該值將被平方,以計算出允許形成孤島區域的最小單元數。例如,值為 8 時將把儲存格的數量設為 64。
SamplePartitionType sample_partition_type = 0 🔗
void set_sample_partition_type(value: SamplePartitionType)
SamplePartitionType get_sample_partition_type()
Partitioning algorithm for creating the navigation mesh polys.
float vertices_per_polygon = 6.0 🔗
在輪廓到多邊形轉換過程中生成的多邊形允許的最大頂點數。
方法說明
void add_polygon(polygon: PackedInt32Array) 🔗
使用呼叫 get_vertices() 得到的頂點的索引新增一個多邊形。
void clear() 🔗
清除頂點和多邊形索引的內部陣列。
void clear_polygons() 🔗
清除多邊形陣列,但不清除頂點陣列。
void create_from_mesh(mesh: Mesh) 🔗
通過根據 Mesh 設定頂點和索引來初始化導覽網格。
注意:給定的 mesh 必須是 Mesh.PRIMITIVE_TRIANGLES 型別,並且有一個索引陣列。
bool get_collision_mask_value(layer_number: int) const 🔗
返回是否啟用了 geometry_collision_mask 中的指定層,給定的 layer_number 在 1 和 32 之間。
PackedInt32Array get_polygon(idx: int) 🔗
返回建立多邊形的頂點索引,形式為 PackedInt32Array。
int get_polygon_count() const 🔗
返回導覽網格中的多邊形數量。
PackedVector3Array get_vertices() const 🔗
返回用於建立該多邊形的所有頂點,形式為 PackedVector3Array。
void set_collision_mask_value(layer_number: int, value: bool) 🔗
根據 value 啟用或禁用 geometry_collision_mask 中的指定層,給定的 layer_number 在 1 和 32 之間。
void set_vertices(vertices: PackedVector3Array) 🔗
設定頂點,可以使用 add_polygon() 方法對其進行索引,建立多邊形。