Table of Contents

Class NavigationMesh

Namespace
Godot
Assembly
GodotSharp.dll

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.

public class NavigationMesh : Resource, IDisposable
Inheritance
NavigationMesh
Implements
Inherited Members

Constructors

NavigationMesh()

public NavigationMesh()

Properties

AgentHeight

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 of CellHeight.

public float AgentHeight { get; set; }

Property Value

float

AgentMaxClimb

The minimum ledge height that is considered to still be traversable.

Note: While baking, this value will be rounded down to the nearest multiple of CellHeight.

public float AgentMaxClimb { get; set; }

Property Value

float

AgentMaxSlope

The maximum slope that is considered walkable, in degrees.

public float AgentMaxSlope { get; set; }

Property Value

float

AgentRadius

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 CellSize.

public float AgentRadius { get; set; }

Property Value

float

CellHeight

The cell height used to rasterize the navigation mesh vertices on the Y axis. Must match with the cell height on the navigation map.

public float CellHeight { get; set; }

Property Value

float

CellSize

The cell size used to rasterize the navigation mesh vertices on the XZ plane. Must match with the cell size on the navigation map.

public float CellSize { get; set; }

Property Value

float

DetailSampleDistance

The sampling distance to use when generating the detail mesh, in cell unit.

public float DetailSampleDistance { get; set; }

Property Value

float

DetailSampleMaxError

The maximum distance the detail mesh surface should deviate from heightfield, in cell unit.

public float DetailSampleMaxError { get; set; }

Property Value

float

EdgeMaxError

The maximum distance a simplified contour's border edges should deviate the original raw contour.

public float EdgeMaxError { get; set; }

Property Value

float

EdgeMaxLength

The maximum allowed length for contour edges along the border of the mesh. A value of 0.0 disables this feature.

Note: While baking, this value will be rounded up to the nearest multiple of CellSize.

public float EdgeMaxLength { get; set; }

Property Value

float

FilterBakingAabb

If the baking Aabb has a volume the navigation mesh baking will be restricted to its enclosing area.

public Aabb FilterBakingAabb { get; set; }

Property Value

Aabb

FilterBakingAabbOffset

The position offset applied to the FilterBakingAabbAabb.

public Vector3 FilterBakingAabbOffset { get; set; }

Property Value

Vector3

FilterLedgeSpans

If true, marks spans that are ledges as non-walkable.

public bool FilterLedgeSpans { get; set; }

Property Value

bool

FilterLowHangingObstacles

If true, marks non-walkable spans as walkable if their maximum is within AgentMaxClimb of a walkable neighbor.

public bool FilterLowHangingObstacles { get; set; }

Property Value

bool

FilterWalkableLowHeightSpans

If true, marks walkable spans as not walkable if the clearance above the span is less than AgentHeight.

public bool FilterWalkableLowHeightSpans { get; set; }

Property Value

bool

GeometryCollisionMask

The physics layers to scan for static colliders.

Only used when GeometryParsedGeometryType is StaticColliders or Both.

public uint GeometryCollisionMask { get; set; }

Property Value

uint

GeometryParsedGeometryType

Determines which type of nodes will be parsed as geometry. See NavigationMesh.ParsedGeometryType for possible values.

public NavigationMesh.ParsedGeometryType GeometryParsedGeometryType { get; set; }

Property Value

NavigationMesh.ParsedGeometryType

GeometrySourceGeometryMode

The source of the geometry used when baking. See NavigationMesh.SourceGeometryMode for possible values.

public NavigationMesh.SourceGeometryMode GeometrySourceGeometryMode { get; set; }

Property Value

NavigationMesh.SourceGeometryMode

GeometrySourceGroupName

The name of the group to scan for geometry.

Only used when GeometrySourceGeometryMode is GroupsWithChildren or GroupsExplicit.

public StringName GeometrySourceGroupName { get; set; }

Property Value

StringName

Polygons

public Array Polygons { get; set; }

Property Value

Array

RegionMergeSize

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.

public float RegionMergeSize { get; set; }

Property Value

float

RegionMinSize

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.

public float RegionMinSize { get; set; }

Property Value

float

SamplePartitionType

Partitioning algorithm for creating the navigation mesh polys. See NavigationMesh.SamplePartitionTypeEnum for possible values.

public NavigationMesh.SamplePartitionTypeEnum SamplePartitionType { get; set; }

Property Value

NavigationMesh.SamplePartitionTypeEnum

Vertices

public Vector3[] Vertices { get; set; }

Property Value

Vector3[]

VerticesPerPolygon

The maximum number of vertices allowed for polygons generated during the contour to polygon conversion process.

public float VerticesPerPolygon { get; set; }

Property Value

float

Methods

AddPolygon(int[])

Adds a polygon using the indices of the vertices you get when calling Godot.NavigationMesh.GetVertices.

public void AddPolygon(int[] polygon)

Parameters

polygon int[]

Clear()

Clears the internal arrays for vertices and polygon indices.

public void Clear()

ClearPolygons()

Clears the array of polygons, but it doesn't clear the array of vertices.

public void ClearPolygons()

CreateFromMesh(Mesh)

Initializes the navigation mesh by setting the vertices and indices according to a Mesh.

Note: The given mesh must be of type Triangles and have an index array.

public void CreateFromMesh(Mesh mesh)

Parameters

mesh Mesh

GetCollisionMaskValue(int)

Returns whether or not the specified layer of the GeometryCollisionMask is enabled, given a layerNumber between 1 and 32.

public bool GetCollisionMaskValue(int layerNumber)

Parameters

layerNumber int

Returns

bool

GetPolygon(int)

Returns a int[] containing the indices of the vertices of a created polygon.

public int[] GetPolygon(int idx)

Parameters

idx int

Returns

int[]

GetPolygonCount()

Returns the number of polygons in the navigation mesh.

public int GetPolygonCount()

Returns

int

HasGodotClassMethod(in godot_string_name)

Check if the type contains a method with the given name. This method is used by Godot to check if a method exists before invoking it. Do not call or override this method.

protected override bool HasGodotClassMethod(in godot_string_name method)

Parameters

method godot_string_name

Name of the method to check for.

Returns

bool

HasGodotClassSignal(in godot_string_name)

Check if the type contains a signal with the given name. This method is used by Godot to check if a signal exists before raising it. Do not call or override this method.

protected override bool HasGodotClassSignal(in godot_string_name signal)

Parameters

signal godot_string_name

Name of the signal to check for.

Returns

bool

InvokeGodotClassMethod(in godot_string_name, NativeVariantPtrArgs, out godot_variant)

Invokes the method with the given name, using the given arguments. This method is used by Godot to invoke methods from the engine side. Do not call or override this method.

protected override bool InvokeGodotClassMethod(in godot_string_name method, NativeVariantPtrArgs args, out godot_variant ret)

Parameters

method godot_string_name

Name of the method to invoke.

args NativeVariantPtrArgs

Arguments to use with the invoked method.

ret godot_variant

Value returned by the invoked method.

Returns

bool

SetCollisionMaskValue(int, bool)

Based on value, enables or disables the specified layer in the GeometryCollisionMask, given a layerNumber between 1 and 32.

public void SetCollisionMaskValue(int layerNumber, bool value)

Parameters

layerNumber int
value bool