Pathfinding API
advanced scriptingTerrain Grid System 2 · Scripting Support (C#)
API Reference
Properties
CanCrossCheckType canCrossCheckTypeCan cross check type.
CanCrossCheckType canCrossCheckTypeCan cross check type.
int cellGroupMaskCell group mask.
int cellGroupMaskCell group mask.
bool cellGroupMaskExactComparisonCell group mask exact comparison.
bool ignoreCellCostsIgnore cell costs.
bool ignoreCellCostsIgnore cell costs.
bool includeInvisibleCellsInclude invisible cells.
bool includeInvisibleCellsInclude invisible cells.
float maxCellCrossCostMax cell cross cost.
float maxSearchCostMax search cost.
float maxSearchCostMax search cost.
int maxStepsMax steps.
int maxStepsMax steps.
int minClearanceMin clearance.
List<int> pathPath.
float pathFindingHeavyDiagonalsCostThe cost for crossing diagonals. (Review: verify this description matches current behavior.)
PathFinding.HeuristicFormula pathFindingHeuristicFormulaThe path finding heuristic formula to estimate distance from current position to destination
bool pathFindingIncludeInvisibleCellsIf true, the path will include invisible cells as well.
float pathFindingMaxCostThe maximum search cost of the path finding execution.
int pathFindingMaxStepsThe maximum number of steps that a path can return.
bool pathFindingUseDiagonalsIf path can include diagonals between cells
bool successSuccess.
float totalCostTotal 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 FindPathAsyncResultResult of an async pathfinding operation
class FindPathOptionsFindPathOptions 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 TGSMultiGridPathFinderTerrainGridSystem[] 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 OnPathFindingCrossCellDataOn path finding cross cell data.
Enums
CanCrossCheckType CanCrossCheckTypeCan cross check type.
CanCrossCheckType CanCrossCheckTypeCan cross check type.
CanCrossCheckType CanCrossCheckTypeCan cross check type.
enum CanCrossCheckTypeSuggest an improvement
Help us improve this documentation page.