NavigationMesh
Experimental: This class may be changed or removed in future versions.
Inherits:Resource<RefCounted<Object
A navigation mesh that defines traversable areas and obstacles.
Description
A navigation mesh is a collection of polygons that define which areas of an environment are traversable to aid agents in pathfinding through complicated spaces.
Tutorials
Properties
| ||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
|
Methods
add_polygon(polygon:PackedInt32Array) | |
clear() | |
create_from_mesh(mesh:Mesh) | |
get_collision_mask_value(layer_number:int)const | |
get_polygon(idx:int) | |
set_collision_mask_value(layer_number:int, value:bool) | |
set_vertices(vertices:PackedVector3Array) |
Enumerations
enumSamplePartitionType:🔗
SamplePartitionTypeSAMPLE_PARTITION_WATERSHED =0
Watershed partitioning. Generally the best choice if you precompute the navigation mesh, use this if you have large open areas.
SamplePartitionTypeSAMPLE_PARTITION_MONOTONE =1
Monotone partitioning. Use this if you want fast navigation mesh generation.
SamplePartitionTypeSAMPLE_PARTITION_LAYERS =2
Layer partitioning. Good choice to use for tiled navigation mesh with medium and small sized tiles.
SamplePartitionTypeSAMPLE_PARTITION_MAX =3
Represents the size of theSamplePartitionType enum.
enumParsedGeometryType:🔗
ParsedGeometryTypePARSED_GEOMETRY_MESH_INSTANCES =0
Parses mesh instances as geometry. This includesMeshInstance3D,CSGShape3D, andGridMap nodes.
ParsedGeometryTypePARSED_GEOMETRY_STATIC_COLLIDERS =1
ParsesStaticBody3D colliders as geometry. The collider should be in any of the layers specified bygeometry_collision_mask.
ParsedGeometryTypePARSED_GEOMETRY_BOTH =2
BothPARSED_GEOMETRY_MESH_INSTANCES andPARSED_GEOMETRY_STATIC_COLLIDERS.
ParsedGeometryTypePARSED_GEOMETRY_MAX =3
Represents the size of theParsedGeometryType enum.
enumSourceGeometryMode:🔗
SourceGeometryModeSOURCE_GEOMETRY_ROOT_NODE_CHILDREN =0
Scans the child nodes of the root node recursively for geometry.
SourceGeometryModeSOURCE_GEOMETRY_GROUPS_WITH_CHILDREN =1
Scans nodes in a group and their child nodes recursively for geometry. The group is specified bygeometry_source_group_name.
SourceGeometryModeSOURCE_GEOMETRY_GROUPS_EXPLICIT =2
Uses nodes in a group for geometry. The group is specified bygeometry_source_group_name.
SourceGeometryModeSOURCE_GEOMETRY_MAX =3
Represents the size of theSourceGeometryMode enum.
Property Descriptions
floatget_agent_height()
The minimum floor to ceiling height that will still allow the floor area to be considered walkable.
Note: While baking, this value will be rounded up to the nearest multiple ofcell_height.
floatget_agent_max_climb()
The minimum ledge height that is considered to still be traversable.
Note: While baking, this value will be rounded down to the nearest multiple ofcell_height.
floatget_agent_max_slope()
The maximum slope that is considered walkable, in degrees.
floatget_agent_radius()
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 ofcell_size.
floatget_border_size()
The size of the non-navigable border around the bake bounding area.
In conjunction with thefilter_baking_aabb and aedge_max_error value at1.0
or below the border size can be used to bake tile aligned navigation meshes without the tile edges being shrunk byagent_radius.
Note: While baking and not zero, this value will be rounded up to the nearest multiple ofcell_size.
floatget_cell_height()
The cell height used to rasterize the navigation mesh vertices on the Y axis. Must match with the cell height on the navigation map.
floatget_cell_size()
The cell size used to rasterize the navigation mesh vertices on the XZ plane. Must match with the cell size on the navigation map.
floatdetail_sample_distance =6.0
🔗
floatget_detail_sample_distance()
The sampling distance to use when generating the detail mesh, in cell unit.
floatdetail_sample_max_error =1.0
🔗
floatget_detail_sample_max_error()
The maximum distance the detail mesh surface should deviate from heightfield, in cell unit.
floatget_edge_max_error()
The maximum distance a simplified contour's border edges should deviate the original raw contour.
floatget_edge_max_length()
The maximum allowed length for contour edges along the border of the mesh. A value of0.0
disables this feature.
Note: While baking, this value will be rounded up to the nearest multiple ofcell_size.
AABBfilter_baking_aabb =AABB(0,0,0,0,0,0)
🔗
AABBget_filter_baking_aabb()
If the bakingAABB has a volume the navigation mesh baking will be restricted to its enclosing area.
Vector3filter_baking_aabb_offset =Vector3(0,0,0)
🔗
Vector3get_filter_baking_aabb_offset()
The position offset applied to thefilter_baking_aabbAABB.
boolfilter_ledge_spans =false
🔗
boolget_filter_ledge_spans()
Iftrue
, marks spans that are ledges as non-walkable.
boolfilter_low_hanging_obstacles =false
🔗
boolget_filter_low_hanging_obstacles()
Iftrue
, marks non-walkable spans as walkable if their maximum is withinagent_max_climb of a walkable neighbor.
boolfilter_walkable_low_height_spans =false
🔗
boolget_filter_walkable_low_height_spans()
Iftrue
, marks walkable spans as not walkable if the clearance above the span is less thanagent_height.
intgeometry_collision_mask =4294967295
🔗
intget_collision_mask()
The physics layers to scan for static colliders.
Only used whengeometry_parsed_geometry_type isPARSED_GEOMETRY_STATIC_COLLIDERS orPARSED_GEOMETRY_BOTH.
ParsedGeometryTypegeometry_parsed_geometry_type =2
🔗
ParsedGeometryTypeget_parsed_geometry_type()
Determines which type of nodes will be parsed as geometry. SeeParsedGeometryType for possible values.
SourceGeometryModegeometry_source_geometry_mode =0
🔗
SourceGeometryModeget_source_geometry_mode()
The source of the geometry used when baking. SeeSourceGeometryMode for possible values.
StringNamegeometry_source_group_name =&"navigation_mesh_source_group"
🔗
StringNameget_source_group_name()
The name of the group to scan for geometry.
Only used whengeometry_source_geometry_mode isSOURCE_GEOMETRY_GROUPS_WITH_CHILDREN orSOURCE_GEOMETRY_GROUPS_EXPLICIT.
floatget_region_merge_size()
Any regions with a size smaller than this will be merged with larger regions if possible.
Note: This value will be squared to calculate the number of cells. For example, a value of 20 will set the number of cells to 400.
floatget_region_min_size()
The minimum size of a region for it to be created.
Note: This value will be squared to calculate the minimum number of cells allowed to form isolated island areas. For example, a value of 8 will set the number of cells to 64.
SamplePartitionTypesample_partition_type =0
🔗
SamplePartitionTypeget_sample_partition_type()
Partitioning algorithm for creating the navigation mesh polys. SeeSamplePartitionType for possible values.
floatvertices_per_polygon =6.0
🔗
floatget_vertices_per_polygon()
The maximum number of vertices allowed for polygons generated during the contour to polygon conversion process.
Method Descriptions
voidadd_polygon(polygon:PackedInt32Array)🔗
Adds a polygon using the indices of the vertices you get when callingget_vertices().
Clears the internal arrays for vertices and polygon indices.
Clears the array of polygons, but it doesn't clear the array of vertices.
voidcreate_from_mesh(mesh:Mesh)🔗
Initializes the navigation mesh by setting the vertices and indices according to aMesh.
Note: The givenmesh
must be of typeMesh.PRIMITIVE_TRIANGLES and have an index array.
boolget_collision_mask_value(layer_number:int)const🔗
Returns whether or not the specified layer of thegeometry_collision_mask is enabled, given alayer_number
between 1 and 32.
PackedInt32Arrayget_polygon(idx:int)🔗
Returns aPackedInt32Array containing the indices of the vertices of a created polygon.
Returns the number of polygons in the navigation mesh.
PackedVector3Arrayget_vertices()const🔗
Returns aPackedVector3Array containing all the vertices being used to create the polygons.
voidset_collision_mask_value(layer_number:int, value:bool)🔗
Based onvalue
, enables or disables the specified layer in thegeometry_collision_mask, given alayer_number
between 1 and 32.
voidset_vertices(vertices:PackedVector3Array)🔗
Sets the vertices that can be then indexed to create polygons with theadd_polygon() method.