reckfellENGINE

VoxelAStarGrid3D

Grid-based A* pathfinding algorithm adapted to blocky voxel terrain.

On this page
class VoxelAStarGrid3DReckfellSharpInherits RefCounted

Grid-based A* pathfinding algorithm adapted to blocky voxel terrain.

This can be used to find paths between two voxel positions on blocky terrain. It is tuned for agents 2 voxels tall and 1 voxel wide, which must stand on solid voxels and can jump 1 voxel high. No navmesh is required, it uses voxels directly with no baking. However, search radius is limited by an area (50 voxels and above starts to be relatively expensive). At the moment, this pathfinder only considers voxels with ID 0 to be air, and the rest is considered solid. Note: "positions" in this class are expected to be in voxels. If your terrain is offset or if voxels are smaller or bigger than world units, you may have to convert coordinates.

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

Constructors1

VoxelAStarGrid3DConstructor
# VoxelAStarGrid3D
C#
public VoxelAStarGrid3D();

Methods7

DebugGetVisitedPositionsReckfell.Collections.Array<Vector3I>
# DebugGetVisitedPositions
C#
public Reckfell.Collections.Array<Vector3I> DebugGetVisitedPositions();

Gets the list of voxel positions that were visited by the last pathfinding request (relates to how A* works under the hood). This is for debugging.

Returns Reckfell.Collections.Array<Vector3I>
FindPathReckfell.Collections.Array<Vector3I>
# FindPath
C#
public Reckfell.Collections.Array<Vector3I> FindPath(Vector3I fromPosition, Vector3I toPosition);

Calculates a path starting from a voxel position to a target voxel position. Those positions should be air voxels just above ground with enough room for agents to fit in. The returned path will be a series of contiguous voxel positions to walk through in order to get to the destination. If no path is found, or if either start or destination position is outside of the search area, an empty array will be returned. You may also use VoxelAStarGrid3D.SetRegion to specify the search area.

Parameters
NameTypeDefault
fromPositionVector3I—
toPositionVector3I—
Returns Reckfell.Collections.Array<Vector3I>
FindPathAsyncvoid
# FindPathAsync
C#
public void FindPathAsync(Vector3I fromPosition, Vector3I toPosition);

Same as VoxelAStarGrid3D.FindPath, but performs the calculation on a separate thread. The result will be emitted with the VoxelAStarGrid3D.AsyncSearchCompleted signal. Only one asynchronous search can be active at a given time. Use VoxelAStarGrid3D.IsRunningAsync to check this.

Parameters
NameTypeDefault
fromPositionVector3I—
toPositionVector3I—
GetRegionAabb
# GetRegion
C#
public Aabb GetRegion();

Gets the maximum region limit that will be considered for pathfinding, in voxels.

Returns Aabb
IsRunningAsyncbool
# IsRunningAsync
C#
public bool IsRunningAsync();

Returns true if a path is currently being calculated asynchronously. See VoxelAStarGrid3D.FindPathAsync.

Returns bool
SetRegionvoid
# SetRegion
C#
public void SetRegion(Aabb box);

Sets the maximum region limit that will be considered for pathfinding, in voxels. You should usually set this before calling VoxelAStarGrid3D.FindPath. The larger the region, the more expensive the search can get. Keep in mind voxel volumes scale cubically, so don't use this on large areas (for example 50 voxels is quite big).

Parameters
NameTypeDefault
boxAabb—
SetTerrainvoid
# SetTerrain
C#
public void SetTerrain(VoxelTerrain terrain);

Sets the terrain that will be used to do searches in.

Parameters
NameTypeDefault
terrainVoxelTerrain—

Signals and events1

AsyncSearchCompletedEvent
# AsyncSearchCompleted
C#
public event VoxelAStarGrid3D.AsyncSearchCompletedEventHandler AsyncSearchCompleted;

Emitted when searches triggered with VoxelAStarGrid3D.FindPathAsync are complete.

Handler parameters
NameTypeDefault
pathReckfell.Collections.Array<Vector3I>—
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.