Super Pathfinding system icon

Super Pathfinding System - Scripting API

A very fast Collider-based AI Navigation system written in C# for Unity3D for both small maps and open worlds.

Scripting API Map

Classes

  • SuperPathfinding.cs
  • PathData.cs
  • AISample.cs

Enum

  • ProcessingSpeed
  • RotationType

SuperPathfinding

Class in Corvostudio.SuperPathfinding



Description

Component for path calculation.

Has public methods for calculating and manipulating paths. Usually you should add one of those to every AI, but allows you can also use only one for calculating paths for every AI.

Properties

Name Type Description
Name Type Description
nodeWidth float Witdh of a node. Can be considered as "step distance".
unitRadius float Radius of the pathfinder.
unitHeight float Height of the pathfinder.
unitClimbAngle float Max climb angle for the pathfinder.
unitStepHeight float Max step height for the pathfinder.
scanHeight float Height of the scan area.
scannedLayersMask LayerMask Mask for the calculation.
allowDiagonals bool Allow diagonal movements.
processingSpeed ProcessingSpeed [Performance settings] Max amount of cycles per frame (ONLY DURING RUNTIME).
gridNodesLimit int [Performance settings] Max number nodes in path calculation.
highQualityObstaclesCheck bool [Performance settings] If true, algorithm will take deeper considerations about where pathfinder can and cannot fit, based on his radius.
testPathStartPosition Transform [Test setting] Transform start position for path tests in editor from the inspector.
testPathDestination Transform [Test setting] Transform target for path tests in editor from the inspector.


Public Methods

Name Type Description Arguments
Name Type Description Arguments
GetLastCalculatedPath() PathData Get last calculated data from the PathFinding component.
FindPath() bool Start calculating a path to the given position. If not forced, and another calculation is already progressing, just return false. Calculated PathData can be accessed with GetCalculatedPathData() (Vector3) destination: Destination to reach.
FindPath() bool Start calculating a path from position A to B. Can also take a callback to return calculated path and force other calculations to stop. Calculated PathData can be accessed with GetCalculatedPathData() or directly sent with a callback. (Vector3) startPos: Start position.
(Vector3) destination: Destination to reach.
(Action) callback: return PathData with callback. [Opional]
(bool) force: Force script to stop any previous calculation and start again. [Opional]
StopAndClear() void Stop all calculations and clear all path data.
SetOnGround() Vector3 Return an adjusted position on the ground, if there is any in the given height range. (Vector3) position: Position to adjust.
(float) range: Range (up and down) where method can adjust position.
IsNearEnoughToDestination() bool Check if node is inside destination range. (PathNode) node: Node to check.
(Vector3) destination: Destination to check.
IsCalculating() bool Return true if component is calculating a path.
CalculatePathNodeColumn() PathNodeColumn Calculate PathNodeColumn if not already done. [Not so udefull for end user] (int)gridI: Shift on Vector3.right*nodeWidth
(int)gridJ: Shift on Vector3.forward*nodeWidth
GetDestination() Vector3 Get last given destination for a path.
IsSlopeAccepted() bool Check if a given direction satisfy slope angle requirements. (Vector3) direction: Direction to check.

PathData

Class in Corvostudio.SuperPathfinding



Description

Structure to store and handle paths calculated from a SuperPathfinding component.

NOTICE: There are two ways to calculate a PathData: Get it with SuperPathfinding.GetLastCalculatedPath() or add a callback in SuperPathfinding.FindPath()'s parameters.

Properties

Name Type Description
Name Type Description


Public Methods

Name Type Description Arguments
Name Type Description Arguments
HavePath() bool Check if the object contains a calulcated path..
CurrentNode() Vector3 Return current active node of the Path.
NextNode() void Skip to next node of the path. First node got discarted and CurrentNode() now returns next node.
ClearPath() void Delete all nodes inside the path.
NodesCount() int Return the number of the remaining nodes in the path.
GetPathAsArray() Vector3[] Return path as Vector3 array of waypoints from the start to the destination of the path.
GetNode() Vector3 Get specific node inside the path. (int) index: Index of the node.

AISample

Class in Corvostudio.SuperPathfinding



Description

Sample class given for considering how to implement this system.

NOTICE: In this version all AI's calculate path at the same time. But concurrent programming is a metter in this kind of algorithm! If you want to get some optimizations in your project, consider allowing only one AI per time to calculate a path.

Properties

Name Type Description
Name Type Description
speed float Speed of the AI while moving along path.
updateRotation RotationType How AI should face direction while moving along path.
pathFindingSystem SuperPathfinding Specify a custom SuperPathfinding component to use (NOTE: can be shared with other SampleAi's for better performance).


Public Methods

Name Type Description Arguments
Name Type Description Arguments
HavePath() bool Check if unit have a calculated path.
GoTo() void Tell to AI to calculate path and move to destination. (Vector3) destination: Destination to reach.
Stop() void Stop calculating, moving and clear path.
UpdatePath() void Calculate path again for assigned destination (if not already doing it).

ProcessingSpeed

Enumeration



Description

Maximum processing speed.

Describes how many cycles between frame skip (at runtime calculation).

Properties

Name Description
ultra Max cycles to 5000 cycles per frame. Usually maximum calculation cycles is much lower, so this is basically like "calculate path in one frame".
veryHigh Max cycles to 1000 cycles per frame.
high Max cycles to 500 cycles per frame.
medium Max cycles to 100 cycles per frame.
low Max cycles to 50 cycles per frame.
veryLow Max cycles to 10 cycles per frame. Even a potato should be able to manage this low quantity of cycles. If you have performance issues even with this value, maybe you should calculate one or a few SuperPathfinder's paths per time.

RotationType

Enumeration



Description

Rotation behaviour of the AISample pathfinder.

Describes how sample AI should rotate when moving along path..

Properties

Name Description
dontRotate Move PathFinder along path without rotating it.
rotateAll Move PathFinder along path facing moving direction and aligning it with slope.
rotateLeftRight Move PathFinder along path facing moving direction but ignoring slope.
rotateAllLerped Move PathFinder along path facing moving direction but ignoring slope smoothly.
rotateLeftRightLerped Move PathFinder along path facing moving direction but ignoring slope smoothly.

Home
Contacts
Other Projects

© Corvostudio 2020