Pathfinding API

advanced scripting

Terrain Grid System 2 · Scripting Support (C#)

Note: This is an exhaustive index of public members for this API area. Signatures may vary by version; rely on your IDE/autocomplete and the source if needed.

API Reference

Properties

CanCrossCheckType canCrossCheckType

Can cross check type.

CanCrossCheckType canCrossCheckType

Can cross check type.

int cellGroupMask

Cell group mask.

int cellGroupMask

Cell group mask.

bool cellGroupMaskExactComparison

Cell group mask exact comparison.

bool ignoreCellCosts

Ignore cell costs.

bool ignoreCellCosts

Ignore cell costs.

bool includeInvisibleCells

Include invisible cells.

bool includeInvisibleCells

Include invisible cells.

float maxCellCrossCost

Max cell cross cost.

float maxSearchCost

Max search cost.

float maxSearchCost

Max search cost.

int maxSteps

Max steps.

int maxSteps

Max steps.

int minClearance

Min clearance.

List<int> path

Path.

float pathFindingHeavyDiagonalsCost

The cost for crossing diagonals. (Review: verify this description matches current behavior.)

PathFinding.HeuristicFormula pathFindingHeuristicFormula

The path finding heuristic formula to estimate distance from current position to destination

bool pathFindingIncludeInvisibleCells

If true, the path will include invisible cells as well.

float pathFindingMaxCost

The maximum search cost of the path finding execution.

int pathFindingMaxSteps

The maximum number of steps that a path can return.

bool pathFindingUseDiagonals

If path can include diagonals between cells

bool success

Success.

float totalCost

Total cost.

Methods

List<PathFinderNode> FindPath(TerrainGridSystem tgs, Cell startCell, Cell endCell, out float totalCost, bool evenLayout)

Finds path.

List<PathFinderNode> FindPath(TerrainGridSystem tgs, Cell startCell, Cell endCell, out float totalCost, bool evenLayout)

Finds path.

List<PathFinderNode> FindPath(TerrainGridSystem tgs, Cell startCell, Cell endCell, out float totalCost, bool evenLayout)

Finds path.

int FindPath(TerrainGridSystem startGrid, Cell startCell, TerrainGridSystem endGrid, Cell endCell, List<(TerrainGridSystem grid, int cellIndex)> path, out float totalCost, FindPathOptions options = null)

Finds a path between two cells that can be in different grids with specified options

List<int> FindPath(int cellIndexStart, int cellIndexEnd, float maxSearchCost = 0, int maxSteps = 0, int cellGroupMask = -1, CanCrossCheckType canCrossCheckType = CanCrossCheckType.Default, bool ignoreCellCosts = false, bool includeInvisibleCells = true, int minClearance = 1, float maxCellCrossCost = float.MaxValue, bool cellGroupMaskExactComparison = false)

Returns an optimal path from startPosition to endPosition with options.

Returns: The route consisting of a list of cell indexes.

List<int> FindPath(int cellIndexStart, int cellIndexEnd, out float totalCost, float maxSearchCost = 0, int maxSteps = 0, int cellGroupMask = -1, CanCrossCheckType canCrossCheckType = CanCrossCheckType.Default, bool ignoreCellCosts = false, bool includeInvisibleCells = true, int minClearance = 1, float maxCellCrossCost = float.MaxValue, bool cellGroupMaskExactComparison = false)

Returns an optimal path from startPosition to endPosition with options.

Returns: The route consisting of a list of cell indexes.

int FindPath(int cellIndexStart, int cellIndexEnd, List<int> cellIndices, out float totalCost, float maxSearchCost = 0, int maxSteps = 0, int cellGroupMask = -1, CanCrossCheckType canCrossCheckType = CanCrossCheckType.Default, bool ignoreCellCosts = false, bool includeInvisibleCells = true, int minClearance = 1, float maxCellCrossCost = float.MaxValue, bool cellGroupMaskExactComparison = false)

Returns an optimal path from startPosition to endPosition with options.

Returns: The route consisting of a list of cell indexes.

int FindPath(int cellIndexStart, int cellIndexEnd, List<int> cellIndices, out float totalCost, FindPathOptions options)

Returns an optimal path from startPosition to endPosition with options.

Returns: The route consisting of a list of cell indexes.

void FindPathAsync(int cellIndexStart, int cellIndexEnd, Action<FindPathAsyncResult> onComplete, FindPathOptions options = null)

Finds a path asynchronously on a background thread. Thread-safe. Results are returned via callback on the main thread. IMPORTANT: Do not modify grid structure while async pathfinding is in progress.

Task<FindPathAsyncResult> FindPathAsync(int cellIndexStart, int cellIndexEnd, FindPathOptions options = null)

Finds a path asynchronously and returns a Task. Thread-safe. IMPORTANT: Do not modify grid structure while async pathfinding is in progress.

struct FindPathAsyncResult

Result of an async pathfinding operation

class FindPathOptions
FindPathOptions GetDefaultOptions()

Gets default options.

void AddConnection(TerrainGridSystem grid1, int cellIndex1, TerrainGridSystem grid2, int cellIndex2, float cost = 1f)

Adds a connection between two cells in different grids

bool AddConnection(Vector3 pointA, Vector3 pointB, float cost = 1f)

Adds a connection between two world positions. Returns true if a valid connection was created.

void ClearConnections()

Clears connections.

void ClearConnections()

Clears connections.

class TGSMultiGridPathFinder
TGSMultiGridPathFinder(TerrainGridSystem[] grids)

Performs tgs multi grid path finder.

Events & Delegates

event PathFindingEvent OnPathFindingCrossCell(TerrainGridSystem tgs, int cellIndex)

Fired when path finding algorithmn evaluates a cell. Use this event to return any extra cost for crossing the cell or 0 to keep the cost at 1.

PathFindingEvent OnPathFindingCrossCell(TerrainGridSystem tgs, int cellIndex)

On path finding cross cell.

object OnPathFindingCrossCellData

On path finding cross cell data.

Enums

CanCrossCheckType CanCrossCheckType

Can cross check type.

CanCrossCheckType CanCrossCheckType

Can cross check type.

CanCrossCheckType CanCrossCheckType

Can cross check type.

enum CanCrossCheckType
Was this page helpful?