reckfellENGINE

NavigationPolygon

A 2D navigation mesh that describes a traversable surface for pathfinding.

On this page
class NavigationPolygonReckfellSharpInherits Resource

A 2D navigation mesh that describes a traversable surface for pathfinding.

A navigation mesh can be created either by baking it with the help of the NavigationServer2D, or by adding vertices and convex polygon indices arrays manually. To bake a navigation mesh at least one outline needs to be added that defines the outer bounds of the baked area.

C#
var newNavigationMesh = new NavigationPolygon();
Vector2[] boundingOutline = [new Vector2(0, 0), new Vector2(0, 50), new Vector2(50, 50), new Vector2(50, 0)];
newNavigationMesh.AddOutline(boundingOutline);
NavigationServer2D.BakeFromSourceGeometryData(newNavigationMesh, new NavigationMeshSourceGeometryData2D());
GetEntity<NavigationRegion2D>("NavigationRegion2D").NavigationPolygon = newNavigationMesh;

Adding vertices and polygon indices manually.

C#
var newNavigationMesh = new NavigationPolygon();
Vector2[] newVertices = [new Vector2(0, 0), new Vector2(0, 50), new Vector2(50, 50), new Vector2(50, 0)];
newNavigationMesh.Vertices = newVertices;
int[] newPolygonIndices = [0, 1, 2, 3];
newNavigationMesh.AddPolygon(newPolygonIndices);
GetEntity<NavigationRegion2D>("NavigationRegion2D").NavigationPolygon = newNavigationMesh;

Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.

Constructors1

NavigationPolygonConstructor
# NavigationPolygon
C#
public NavigationPolygon();

Properties13

AgentRadiusProperty
# AgentRadius
C#
public float AgentRadius { get; set; }

Clearance radius used when baking traversable geometry. Changing it does not automatically rebake existing output; inspect boundaries and paths after baking. It is not a physics-shape or avoidance radius.

BakingRectProperty
# BakingRect
C#
public Rect2 BakingRect { get; set; }

If the baking Rect2 has an area the navigation mesh baking will be restricted to its enclosing area.

BakingRectOffsetProperty
# BakingRectOffset
C#
public Vector2 BakingRectOffset { get; set; }

The position offset applied to the NavigationPolygon.BakingRect Rect2.

BorderSizeProperty
# BorderSize
C#
public float BorderSize { get; set; }

The size of the non-navigable border around the bake bounding area defined by the NavigationPolygon.BakingRect Rect2. In conjunction with the NavigationPolygon.BakingRect the border size can be used to bake tile aligned navigation meshes without the tile edges being shrunk by NavigationPolygon.AgentRadius.

CellSizeProperty
# CellSize
C#
public float CellSize { get; set; }

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

OutlinesProperty
# Outlines
C#
public Reckfell.Collections.Array<Vector2[]> Outlines { get; set; }
ParsedCollisionMaskProperty
# ParsedCollisionMask
C#
public uint ParsedCollisionMask { get; set; }

The physics layers to scan for static colliders. Only used when NavigationPolygon.ParsedGeometryType is NavigationPolygon.ParsedGeometryTypeEnum.StaticColliders or NavigationPolygon.ParsedGeometryTypeEnum.Both.

ParsedGeometryTypeProperty
# ParsedGeometryType
C#
public NavigationPolygon.ParsedGeometryTypeEnum ParsedGeometryType { get; set; }

Determines which type of nodes will be parsed as geometry.

PolygonsProperty
# Polygons
C#
public Reckfell.Collections.Array<int[]> Polygons { get; set; }
SamplePartitionTypeProperty
# SamplePartitionType
C#
public NavigationPolygon.SamplePartitionTypeEnum SamplePartitionType { get; set; }

Partitioning algorithm for creating the navigation mesh polys.

SourceGeometryGroupNameProperty
# SourceGeometryGroupName
C#
public StringName SourceGeometryGroupName { get; set; }

The group name of nodes that should be parsed for baking source geometry. Only used when NavigationPolygon.SourceGeometryMode is NavigationPolygon.SourceGeometryModeEnum.GroupsWithChildren or NavigationPolygon.SourceGeometryModeEnum.GroupsExplicit.

SourceGeometryModeProperty
# SourceGeometryMode
C#
public NavigationPolygon.SourceGeometryModeEnum SourceGeometryMode { get; set; }

The source of the geometry used when baking.

VerticesProperty
# Vertices
C#
public Vector2[] Vertices { get; set; }

Methods43

AddOutline2 overloads
# AddOutline · 1/2
C#
public void AddOutline(Vector2[] outline);

Appends a Vector2[] that contains the vertices of an outline to the internal array that contains all the outlines.

Parameters
NameTypeDefault
outlineVector2[]—
# AddOutline · 2/2
C#
public void AddOutline(ReadOnlySpan<Vector2> outline);

Appends a Vector2[] that contains the vertices of an outline to the internal array that contains all the outlines.

Parameters
NameTypeDefault
outlineReadOnlySpan<Vector2>—
AddOutlineAtIndex2 overloads
# AddOutlineAtIndex · 1/2
C#
public void AddOutlineAtIndex(Vector2[] outline, int index);

Adds a Vector2[] that contains the vertices of an outline to the internal array that contains all the outlines at a fixed position.

Parameters
NameTypeDefault
outlineVector2[]—
indexint—
# AddOutlineAtIndex · 2/2
C#
public void AddOutlineAtIndex(ReadOnlySpan<Vector2> outline, int index);

Adds a Vector2[] that contains the vertices of an outline to the internal array that contains all the outlines at a fixed position.

Parameters
NameTypeDefault
outlineReadOnlySpan<Vector2>—
indexint—
AddPolygon2 overloads
# AddPolygon · 1/2
C#
public void AddPolygon(int[] polygon);

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

Parameters
NameTypeDefault
polygonint[]—
# AddPolygon · 2/2
C#
public void AddPolygon(ReadOnlySpan<int> polygon);

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

Parameters
NameTypeDefault
polygonReadOnlySpan<int>—
Clearvoid
# Clear
C#
public void Clear();

Clears the internal arrays for vertices and polygon indices.

ClearOutlinesvoid
# ClearOutlines
C#
public void ClearOutlines();

Clears the array of the outlines, but it doesn't clear the vertices and the polygons that were created by them.

ClearPolygonsvoid
# ClearPolygons
C#
public void ClearPolygons();

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

GetAgentRadiusfloat
# GetAgentRadius
C#
public float GetAgentRadius();
Returns float
GetBakingRectRect2
# GetBakingRect
C#
public Rect2 GetBakingRect();
Returns Rect2
GetBakingRectOffsetVector2
# GetBakingRectOffset
C#
public Vector2 GetBakingRectOffset();
Returns Vector2
GetBorderSizefloat
# GetBorderSize
C#
public float GetBorderSize();
Returns float
GetCellSizefloat
# GetCellSize
C#
public float GetCellSize();
Returns float
GetNavigationMeshNavigationMesh
# GetNavigationMesh
C#
public NavigationMesh GetNavigationMesh();

Returns the NavigationMesh resulting from this navigation polygon. This navigation mesh can be used to update the navigation mesh of a region with the NavigationServer3D.RegionSetNavigationMesh API directly.

Returns NavigationMesh
GetOutlineVector2[]
# GetOutline
C#
public Vector2[] GetOutline(int idx);

Returns a Vector2[] containing the vertices of an outline that was created in the editor or by script.

Parameters
NameTypeDefault
idxint—
Returns Vector2[]
GetOutlineCountint
# GetOutlineCount
C#
public int GetOutlineCount();

Returns the number of outlines that were created in the editor or by script.

Returns int
GetParsedCollisionMaskuint
# GetParsedCollisionMask
C#
public uint GetParsedCollisionMask();
Returns uint
GetParsedCollisionMaskValuebool
# GetParsedCollisionMaskValue
C#
public bool GetParsedCollisionMaskValue(int layerNumber);

Returns whether or not the specified layer of the NavigationPolygon.ParsedCollisionMask is enabled, given a layer_number between 1 and 32.

Parameters
NameTypeDefault
layerNumberint—
Returns bool
GetParsedGeometryTypeNavigationPolygon.ParsedGeometryTypeEnum
# GetParsedGeometryType
C#
public NavigationPolygon.ParsedGeometryTypeEnum GetParsedGeometryType();
Returns NavigationPolygon.ParsedGeometryTypeEnum
GetPolygonint[]
# GetPolygon
C#
public int[] GetPolygon(int idx);

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

Parameters
NameTypeDefault
idxint—
Returns int[]
GetPolygonCountint
# GetPolygonCount
C#
public int GetPolygonCount();

Returns the navigation resource polygon count. A positive count establishes data presence, rather than map readiness, target reachability or physical character clearance.

Returns int

Polygon count; zero means this resource has no prepared polygons.

GetSamplePartitionTypeNavigationPolygon.SamplePartitionTypeEnum
# GetSamplePartitionType
C#
public NavigationPolygon.SamplePartitionTypeEnum GetSamplePartitionType();
Returns NavigationPolygon.SamplePartitionTypeEnum
GetSourceGeometryGroupNameStringName
# GetSourceGeometryGroupName
C#
public StringName GetSourceGeometryGroupName();
Returns StringName
GetSourceGeometryModeNavigationPolygon.SourceGeometryModeEnum
# GetSourceGeometryMode
C#
public NavigationPolygon.SourceGeometryModeEnum GetSourceGeometryMode();
Returns NavigationPolygon.SourceGeometryModeEnum
GetVerticesVector2[]
# GetVertices
C#
public Vector2[] GetVertices();

Returns a Vector2[] containing all the vertices being used to create the polygons.

Returns Vector2[]
MakePolygonsFromOutlinesvoid · Deprecated
# MakePolygonsFromOutlines
C#
public void MakePolygonsFromOutlines();

Creates polygons from the outlines added in the editor or by script.

RemoveOutlinevoid
# RemoveOutline
C#
public void RemoveOutline(int idx);

Removes an outline created in the editor or by script. You have to call NavigationPolygon.MakePolygonsFromOutlines for the polygons to update.

Parameters
NameTypeDefault
idxint—
SetAgentRadiusvoid
# SetAgentRadius
C#
public void SetAgentRadius(float agentRadius);
Parameters
NameTypeDefault
agentRadiusfloat—
SetBakingRectvoid
# SetBakingRect
C#
public void SetBakingRect(Rect2 rect);
Parameters
NameTypeDefault
rectRect2—
SetBakingRectOffsetvoid
# SetBakingRectOffset
C#
public void SetBakingRectOffset(Vector2 rectOffset);
Parameters
NameTypeDefault
rectOffsetVector2—
SetBorderSizevoid
# SetBorderSize
C#
public void SetBorderSize(float borderSize);
Parameters
NameTypeDefault
borderSizefloat—
SetCellSizevoid
# SetCellSize
C#
public void SetCellSize(float cellSize);
Parameters
NameTypeDefault
cellSizefloat—
SetOutline2 overloads
# SetOutline · 1/2
C#
public void SetOutline(int idx, Vector2[] outline);

Changes an outline created in the editor or by script. You have to call NavigationPolygon.MakePolygonsFromOutlines for the polygons to update.

Parameters
NameTypeDefault
idxint—
outlineVector2[]—
# SetOutline · 2/2
C#
public void SetOutline(int idx, ReadOnlySpan<Vector2> outline);

Changes an outline created in the editor or by script. You have to call NavigationPolygon.MakePolygonsFromOutlines for the polygons to update.

Parameters
NameTypeDefault
idxint—
outlineReadOnlySpan<Vector2>—
SetParsedCollisionMaskvoid
# SetParsedCollisionMask
C#
public void SetParsedCollisionMask(uint mask);
Parameters
NameTypeDefault
maskuint—
SetParsedCollisionMaskValuevoid
# SetParsedCollisionMaskValue
C#
public void SetParsedCollisionMaskValue(int layerNumber, bool value);

Based on value, enables or disables the specified layer in the NavigationPolygon.ParsedCollisionMask, given a layer_number between 1 and 32.

Parameters
NameTypeDefault
layerNumberint—
valuebool—
SetParsedGeometryTypevoid
# SetParsedGeometryType
C#
public void SetParsedGeometryType(NavigationPolygon.ParsedGeometryTypeEnum geometryType);
Parameters
NameTypeDefault
geometryTypeNavigationPolygon.ParsedGeometryTypeEnum—
SetSamplePartitionTypevoid
# SetSamplePartitionType
C#
public void SetSamplePartitionType(NavigationPolygon.SamplePartitionTypeEnum samplePartitionType);
Parameters
NameTypeDefault
samplePartitionTypeNavigationPolygon.SamplePartitionTypeEnum—
SetSourceGeometryGroupNamevoid
# SetSourceGeometryGroupName
C#
public void SetSourceGeometryGroupName(StringName groupName);
Parameters
NameTypeDefault
groupNameStringName—
SetSourceGeometryModevoid
# SetSourceGeometryMode
C#
public void SetSourceGeometryMode(NavigationPolygon.SourceGeometryModeEnum geometryMode);
Parameters
NameTypeDefault
geometryModeNavigationPolygon.SourceGeometryModeEnum—
SetVertices2 overloads
# SetVertices · 1/2
C#
public void SetVertices(Vector2[] vertices);

Sets the vertices that can be then indexed to create polygons with the NavigationPolygon.AddPolygon method.

Parameters
NameTypeDefault
verticesVector2[]—
# SetVertices · 2/2
C#
public void SetVertices(ReadOnlySpan<Vector2> vertices);

Sets the vertices that can be then indexed to create polygons with the NavigationPolygon.AddPolygon method.

Parameters
NameTypeDefault
verticesReadOnlySpan<Vector2>—

NavigationPolygon.ParsedGeometryTypeEnum

ValueDescription
Both = 2

Both NavigationPolygon.ParsedGeometryTypeEnum.MeshInstances and NavigationPolygon.ParsedGeometryTypeEnum.StaticColliders.

Max = 3

Represents the size of the NavigationPolygon.ParsedGeometryTypeEnum enum.

MeshInstances = 0

Parses mesh instances as obstruction geometry. This includes Polygon2D, MeshInstance2D, MultiMeshInstance2D, and TileMap nodes. Meshes are only parsed when they use a 2D vertices surface format.

StaticColliders = 1

Parses StaticBody2D and TileMap colliders as obstruction geometry. The collider should be in any of the layers specified by NavigationPolygon.ParsedCollisionMask.

NavigationPolygon.SamplePartitionTypeEnum

ValueDescription
ConvexPartition = 0

Convex partitioning that results in a navigation mesh with convex polygons.

Max = 2

Represents the size of the NavigationPolygon.SamplePartitionTypeEnum enum.

Triangulate = 1

Triangulation partitioning that results in a navigation mesh with triangle polygons.

NavigationPolygon.SourceGeometryModeEnum

ValueDescription
GroupsExplicit = 2

Uses nodes in a group for geometry. The group is specified by NavigationPolygon.SourceGeometryGroupName.

GroupsWithChildren = 1

Scans nodes in a group and their child nodes recursively for geometry. The group is specified by NavigationPolygon.SourceGeometryGroupName.

Max = 3

Represents the size of the NavigationPolygon.SourceGeometryModeEnum enum.

RootNodeChildren = 0

Scans the child nodes of the root node recursively for geometry.

Reckfell Engine documentationBack to top ↑
QUICK LINKSGetting startedEntity hierarchyC# & .NET 10Scenes and prefabs
Reckfell guides and full API K
reckfellENGINE
RECKFELL ACCOUNT

Sign in

Sign in to your Reckfell account.

One account for the entire Reckfell platform.