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
  • AISample.cs

Enum

  • ProcessingSpeed
  • RotationType

SuperPathfinding

Class in Corvostudio.PathFinding



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.
pathStartPosition Transform Position where path calculation should start from.
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.
testPathDestination Transform [Test setting] Transform target for path tests both in editor and during runtime from the inspector.


Public Methods

Name Type Description Arguments
Name Type Description Arguments
HavePath() bool Check if PathFinder has path ready.
GetPath() Vector3 Return path as Vector3 array of waypoints from the start to the destination of the path.
GetNextPathDestination() Vector3 Return next node of the Path.
NextNode() void Skip to next node of the path. First node got discarted and GetNextPathDestination() now returns next node.
FindPath() bool Start calculating a path to the given position. If not forced, and another calculation is already progressing, doesn't start and return false. (Vector3) destination: Destination to reach.
(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.

AISample

Class in Corvostudio.PathFinding



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.


Public Methods

Name Type Description Arguments
Name Type Description Arguments
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.

Home
Contacts
Newsletter
Other Projects

© Corvostudio 2020