A* Pathfinding Project  3.0.9
The A* Pathfinding Project for Unity
AstarPath Class Reference

Main Pathfinding System. More...

+ Collaboration diagram for AstarPath:

List of all members.

Public Types

enum  AstarDistribution { WebsiteDownload, AssetStore }  
enum  PathfindingStatus {
  None, Searching, Waiting, Locking,
  SearchLoop
}
 

Public Member Functions

int GetNextPathID ()  Returns the next free path ID.
void OnDrawGizmos ()  Calls OnDrawGizmos on graph generators and also OnDrawGizmosCallback.
void OnGUI ()  Draws the InGame debugging (if enabled), also shows the fps if 'L' is pressed down.
void LogPathResults (Path p)  Prints path results to the log.
IEnumerator DelayedGraphUpdate ()  
bool WillBlockPath (GraphUpdateObject ob, Node n1, Node n2)  Will applying this GraphUpdateObject result in no possible path between n1 and n2.
void UpdateGraphs (Bounds bounds, float t)  Update all graphs within bounds after t seconds.
void UpdateGraphs (GraphUpdateObject ob, float t)  Update all graphs using the GraphUpdateObject after t seconds.
void UpdateGraphs (Bounds bounds)  Update all graphs within bounds.
void UpdateGraphs (GraphUpdateObject ob)  Update all graphs using the GraphUpdateObject.
void RegisterCanUpdateGraphs (OnVoidDelegate callback, OnVoidDelegate callback2=null)  
void LogProfiler ()  
void ResetProfiler ()  
void Awake ()  Sets up all needed variables and scanns the graphs.
void SetUpReferences ()  Makes sure active is set to this object and that astarData is not null.
void Initialize ()  Initializes various variables.
void OnDestroy ()  Clears up variables and other stuff, destroys graphs.
void FloodFill (Node seed)  Floodfills starting from the specified node.
void FloodFill (Node seed, int area)  Floodfills starting from 'seed' using the specified area.
void FloodFill ()  Floodfills all graphs and updates areas for every node.
void AutoScan ()  Called by editor scripts to rescan the graphs e.g when the user moved a graph.
void Scan ()  Scanns all graphs.
IEnumerable< ProgressScanLoop ()  Scanns all graphs.
void ApplyLinks ()  Applies links to the scanned graphs.
void OnApplicationQuit ()  Terminates the pathfinding thread when the application quits.
IEnumerator ReturnPaths ()  Coroutine to return thread safe path callbacks when using multithreading.
NNInfo GetNearest (Vector3 position, NNConstraint constraint=null, Node hint=null)  Returns the nearest node to a position using the specified NNConstraint.
Node GetNearest (Ray ray)  Returns the node closest to the ray (slow).
AstarSerializer Savex (NavGraph graph, bool runtime)  Obsolete.
AstarSerializer Loadx (bool runtime, out NavGraph graph)  Obsolete.
AstarSerializer Loadx (bool runtime, out NavGraph graph, AstarSerializer.DeSerializationInterrupt interrupt)  Obsolete.

Static Public Member Functions

static Path GetFromPathPool ()  Get a path from the Path Pool.
static void AddToPathPool (Path p)  Adds the path to the PathPool.
static void SetPathfindingStatus (PathfindingStatus s)  
static void AstarLog (string s)  Logs a string while taking into account logPathResults.
static void AstarLogError (string s)  Logs an error string while taking into account logPathResults.
static bool IsPathPossible (Node n1, Node n2)  Returns if there is a walkable path from n1 to n2.
static void RegisterSafeNodeUpdate (OnVoidDelegate callback)  Will send a callback when it is safe to update nodes.
static void RegisterThreadSafeNodeUpdate (OnVoidDelegate callback)  Will send a callback when it is safe to update nodes.
static IEnumerator DelayedPathReturn (Path p)  
static void StartPath (Path p)  Puts the Path in queue for calculation.
static void CalculatePathsThreaded ()  Main pathfinding function (multithreaded).
static IEnumerator CalculatePaths ()  Main pathfinding function.

Public Variables

const AstarDistribution Distribution = AstarDistribution.WebsiteDownload  Used by the editor to guide the user to the correct place to download updates.
AstarData astarData  Link to the Pathfinding::AstarData object for this graph.
bool showGraphs = false  Shows or hides graph inspectors.
bool showNavGraphs = true  Toggle for showing the gizmo debugging for the graphs in the scene view (editor only).
bool showUnwalkableNodes = true  Toggle to show unwalkable nodes.
bool scanOnStartup = true  If true, all graphs will be scanned in Awake.
bool prioritizeGraphs = false  
float prioritizeGraphsLimit = 1F  
AstarColor colorSettings  Link to the color settings for this AstarPath object.
float lastScanTime = 0F  How long time did the last scan take to complete? Used to prevent automatically rescanning the graphs too often (editor only)
float startUpdate = 0  
Queue< GraphUpdateObjectgraphUpdateQueue  Stack containing all waiting graph update queries.
Stack< NodefloodStack  Stack used for flood-filling the graph.
int lastUniqueAreaIndex = 0  The last area index which was used.
Heuristic heuristic = Heuristic.Euclidean  The heuristic to use.
float heuristicScale = 1F  The scale of the heuristic.
Path debugPath  The path to debug using gizmos.
string inGameDebugPath  This is the debug string from the last completed path.
GraphDebugMode debugMode  The mode to use for drawing nodes in the sceneview.
float debugFloor = 0  Low value to use for certain debugMode modes.
float debugRoof = 10000  High value to use for certain debugMode modes.
bool showSearchTree = false  If enabled, nodes will draw a line to their 'parent'.
float unwalkableNodeDebugSize = 0.3F  Size of the red cubes shown in place of unwalkable nodes.
bool stepByStep = true  If enabled, only one node will be searched per search iteration (frame).
bool useMultithreading = false  Should multithreading be enabled.
float maxFrameTime = 1F  Max number of milliseconds to spend each frame for pathfinding.
BinaryHeap binaryHeap  The open list.
int binaryHeapSize = 5000  The max size of the binary heap.
bool recyclePaths = false  Recycle paths to reduce memory allocations.
int minAreaSize = 10  Defines the minimum amount of nodes in an area.
PathLog logPathResults = PathLog.Normal  The amount of debugging messages.
OnVoidDelegate OnDrawGizmosCallback  Used to enable gizmos in editor scripts.
bool limitGraphUpdates = true  Limit graph updates.
float maxGraphUpdateFreq = 0.2F  How often should graphs be updated.
OnVoidDelegate OnGraphsWillBeUpdated  
OnVoidDelegate OnGraphsWillBeUpdated2  

Static Public Variables

static readonly bool HasPro = true  Used by the editor to show some Pro specific stuff.
static int PathsCompleted = 0  How many paths has been computed this run.
static System.Int64 TotalSearchedNodes = 0  
static System.Int64 TotalSearchTime = 0  
static OnVoidDelegate OnAwakeSettings  Called on Awake before anything else is done.
static OnGraphDelegate OnGraphPreScan  Called for each graph before they are scanned.
static OnGraphDelegate OnGraphPostScan  Called for each graph after they have been scanned.
static OnPathDelegate OnPathPreSearch  Called for each path before searching.
static OnPathDelegate OnPathPostSearch  Called for each path after searching.
static OnScanDelegate OnPreScan  Called before starting the scanning.
static OnScanDelegate OnPostScan  Called after scanning.
static OnScanDelegate OnLatePostScan  Called after scanning has completed fully.
static OnScanDelegate OnGraphsUpdated  Called when any graphs are updated.
static OnVoidDelegate On65KOverflow  Called when pathID overflows 65536.
static OnVoidDelegate OnSafeNodeUpdate  Will send a callback when it is safe to update the nodes.
static OnPathDelegate OnGraphUpdate  Used to update the graphs internally.
static Path pathQueueEnd  Last path added to the pathfinding queue.
static Path pathQueueStart  The next path to be computed (or is being computed)
static Path pathReturnQueueStart  The next path to return using multithreading.
static bool missedPathQueueIncrement = false  Pop the pathfinding queue once when starting pathfinding.
static Thread activeThread  Patfinding thread when using multithreading.
static int threadTimeoutFrames = 2000  Max number of iterations in the pathfinding thread without anything to do before aborting the thread.
static bool isCalculatingPaths = false  True if the pathfinding is running.
static System.Object lockObject = new System.Object ()  Synchronises pathfinding thread and Unity thread for graph updates.
static new AstarPath active  Returns the active AstarPath object in the scene.
static Stack< PathPathPool  Stack to hold paths waiting to be recycled.
static PathfindingStatus pathfindingStatus = PathfindingStatus.None  

Properties

static System.Version Version [get]  The version number for the A* Pathfinding Project.
System.Type[] graphTypes [get]  See Pathfinding::AstarData.
NavGraph[] graphs [get, set]  Shortcut to Pathfinding::AstarData::graphs.

Private Member Functions

bool WillBlockPathInternal (GraphUpdateObject ob, Node n1, Node n2)  
IEnumerator UpdateGraphsInteral (GraphUpdateObject ob, float t)  pdate all graphs using the GraphUpdateObject after t seconds
void DoUpdateGraphs (Path p)  Receives callback from OnGraphUpdate.
void DoUpdateGraphs ()  Updates the graphs based on the graphUpdateQueue.

Private Variables

bool acceptNewPaths = true  Disables or enables new paths to be added to the queue.
int nextFreePathID = 1  The next unused Path ID.
float lastGraphUpdate = -9999F  
bool graphUpdateRoutineRunning = false  
bool isUpdatingGraphs = false  
bool isRegisteredForUpdate = false  

Static Private Variables

static System.Object CalculatePathsLock = new System.Object ()  Lock to use when reading and writing to isCalculatingPaths.

Detailed Description

Main Pathfinding System.

This class handles all the pathfinding system, calculates all paths and stores the info.
This class is a singleton class, meaning it should only exist at most one active instance of it in the scene.
It might be a bit hard to use directly, usually interfacing with the pathfinding system is done through the Seeker class.


Member Enumeration Documentation


Member Function Documentation

static void AddToPathPool ( Path  p) [static]

Adds the path to the PathPool.

Paths are pooled to reduce memory allocations

void ApplyLinks ( )

Applies links to the scanned graphs.

Called right after OnPostScan and before FloodFill().

static void AstarLog ( string  s) [static]

Logs a string while taking into account logPathResults.

static void AstarLogError ( string  s) [static]

Logs an error string while taking into account logPathResults.

void AutoScan ( )

Called by editor scripts to rescan the graphs e.g when the user moved a graph.

void Awake ( )

Sets up all needed variables and scanns the graphs.

Calls Initialize, starts the ReturnPaths coroutine and scanns all graphs.

See also:
OnAwakeSettings
static IEnumerator CalculatePaths ( ) [static]

Main pathfinding function.

This coroutine will calculate the paths in the pathfinding queue.

See also:
CalculatePathsThreaded ()
static void CalculatePathsThreaded ( ) [static]

Main pathfinding function (multithreaded).

This function will calculate the paths in the pathfinding queue when multithreading is enabled.

See also:
CalculatePaths
A* Pro Feature:
This is an A* Pathfinding Project Pro feature only. This function/class/variable might not exist in the Free version of the A* Pathfinding Project or the functionality might be limited
The Pro version can be bought here
void DoUpdateGraphs ( Path  p) [private]

Receives callback from OnGraphUpdate.

See also:
DoUpdateGraphs
void DoUpdateGraphs ( ) [private]

Updates the graphs based on the graphUpdateQueue.

See also:
UpdateGraphs
void FloodFill ( Node  seed)

Floodfills starting from the specified node.

void FloodFill ( Node  seed,
int  area 
)

Floodfills starting from 'seed' using the specified area.

void FloodFill ( )

Floodfills all graphs and updates areas for every node.

See also:
Pathfinding::Node::area
static Path GetFromPathPool ( ) [static]

Get a path from the Path Pool.

If path recycling is off, this will create an entirely new path

NNInfo GetNearest ( Vector3  position,
NNConstraint  constraint = null,
Node  hint = null 
)

Returns the nearest node to a position using the specified NNConstraint.

Searches through all graphs for their nearest nodes to the specified position and picks the closest one.

Node GetNearest ( Ray  ray)

Returns the node closest to the ray (slow).

Warning:
This function is brute-force and is slow, it can barely be used once per frame
int GetNextPathID ( )

Returns the next free path ID.

If the next free path ID overflows 65535, a cleanup operation is queued

See also:
Pathfinding::CleanupPath65K
void Initialize ( )

Initializes various variables.

Sets up references , searches for graph types , creates the binaryHeap and calls Awake on astarData and on all graphs

static bool IsPathPossible ( Node  n1,
Node  n2 
) [static]

Returns if there is a walkable path from n1 to n2.

If you are making changes to the graph, areas must first be recaculated using FloodFill()

Note:
This might return true for small areas even if there is no possible path if minAreaSize is greater than zero (0). So when using this, it is recommended to set minAreaSize to 0.
AstarSerializer Loadx ( bool  runtime,
out NavGraph  graph 
)

Obsolete.

AstarSerializer Loadx ( bool  runtime,
out NavGraph  graph,
AstarSerializer.DeSerializationInterrupt  interrupt 
)

Obsolete.

void LogPathResults ( Path  p)

Prints path results to the log.

What it prints can be controled using logPathResults.

See also:
logPathResults
PathLog
Todo:
Use string builder instead for lower memory footprint

Terminates the pathfinding thread when the application quits.

A* Pro Feature:
This is an A* Pathfinding Project Pro feature only. This function/class/variable might not exist in the Free version of the A* Pathfinding Project or the functionality might be limited
The Pro version can be bought here
void OnDestroy ( )

Clears up variables and other stuff, destroys graphs.

void OnDrawGizmos ( )

Calls OnDrawGizmos on graph generators and also OnDrawGizmosCallback.

void OnGUI ( )

Draws the InGame debugging (if enabled), also shows the fps if 'L' is pressed down.

See also:
logPathResults PathLog
static void RegisterSafeNodeUpdate ( OnVoidDelegate  callback) [static]

Will send a callback when it is safe to update nodes.

This is defined as between the path searches. This callback will only be sent once and is nulled directly after the callback has been sent

Warning:
Note that these callbacks are not thread safe when using multithreading, DO NOT call any part of the Unity API from these callbacks except for Debug.Log
See also:
RegisterThreadSafeNodeUpdate
static void RegisterThreadSafeNodeUpdate ( OnVoidDelegate  callback) [static]

Will send a callback when it is safe to update nodes.

This is defined as between the path searches. This callback will only be sent once and is nulled directly after the callback has been sent. This callback is also threadsafe, and because of that, using it often might affect performance when called often and multithreading is enabled due to locking and synchronisation.

See also:
RegisterSafeNodeUpdate
IEnumerator ReturnPaths ( )

Coroutine to return thread safe path callbacks when using multithreading.

This is always running when multithreading is on, and will be returning paths as fast as possible as the CalculatePathsThreaded function calculates them

A* Pro Feature:
This is an A* Pathfinding Project Pro feature only. This function/class/variable might not exist in the Free version of the A* Pathfinding Project or the functionality might be limited
The Pro version can be bought here
AstarSerializer Savex ( NavGraph  graph,
bool  runtime 
)

Obsolete.

void Scan ( )

Scanns all graphs.

IEnumerable<Progress> ScanLoop ( )

Scanns all graphs.

This is a IEnumerable, you can loop through it to get the progress

 foreach (Progress progress in AstarPath.active.ScanLoop ()) {
     Debug.Log ("Scanning... " + progress.description + " - " + (progress.progress*100).ToString ("0") + "%");
 } 
See also:
Scan
static void SetPathfindingStatus ( PathfindingStatus  s) [static]
Todo:
Remove
void SetUpReferences ( )

Makes sure active is set to this object and that astarData is not null.

Also calls OnEnable for the colorSettings

static void StartPath ( Path  p) [static]

Puts the Path in queue for calculation.

void UpdateGraphs ( Bounds  bounds,
float  t 
)

Update all graphs within bounds after t seconds.

This function will add a GraphUpdateObject to the graphUpdateQueue. The graphs will be updated before the next path is calculated.

See also:
Update
DoUpdateGraphs
void UpdateGraphs ( GraphUpdateObject  ob,
float  t 
)

Update all graphs using the GraphUpdateObject after t seconds.

This can be used to, e.g make all nodes in an area unwalkable, or set them to a higher penalty.

void UpdateGraphs ( Bounds  bounds)

Update all graphs within bounds.

This function will add a GraphUpdateObject to the graphUpdateQueue. The graphs will be updated before the next path is calculated.

See also:
Update
DoUpdateGraphs

Update all graphs using the GraphUpdateObject.

This can be used to, e.g make all nodes in an area unwalkable, or set them to a higher penalty.

IEnumerator UpdateGraphsInteral ( GraphUpdateObject  ob,
float  t 
) [private]

pdate all graphs using the GraphUpdateObject after t seconds

bool WillBlockPath ( GraphUpdateObject  ob,
Node  n1,
Node  n2 
)

Will applying this GraphUpdateObject result in no possible path between n1 and n2.

Use this only with basic GraphUpdateObjects since it needs special backup logic, it probably wont work with your own specialized ones. This function is quite a lot slower than a standart Graph Update, but not so much it will slow the game down.

Note:
This might return false for small areas even if it would block the path if minAreaSize is greater than zero (0). So when using this, it is recommended to set minAreaSize to 0.
See also:
AstarPath::GetNearest

Member Data Documentation

bool acceptNewPaths = true [private]

Disables or enables new paths to be added to the queue.

Setting this to false also makes the pathfinding thread (if using multithreading) to abort as soon as possible. It is used when OnDestroy is called to abort the pathfinding thread.

new AstarPath active [static]

Returns the active AstarPath object in the scene.

Thread activeThread [static]

Patfinding thread when using multithreading.

Link to the Pathfinding::AstarData object for this graph.

The AstarData object stores information about all graphs.

The open list.

A binary heap holds and sorts the open list for the pathfinding. Binary Heaps are extreamly fast in providing a priority queue for the node with the lowest F score.

int binaryHeapSize = 5000

The max size of the binary heap.

A good value is from 80% of the number of nodes in the graphs (for small graphs) to 20% of the number of nodes in the graphs (for large graphs). You will get warning messages if too many nodes are pushed to the open list.

See also:
binaryHeap
Todo:
Add automatic setting (for example, use 40% of the number of nodes in all graphs)
System.Object CalculatePathsLock = new System.Object () [static, private]

Lock to use when reading and writing to isCalculatingPaths.

Link to the color settings for this AstarPath object.

Color settings include for example which color the nodes should be in, in the sceneview.

float debugFloor = 0

Low value to use for certain debugMode modes.

For example if debugMode is set to G, this value will determine when the node will be totally red.

See also:
debugRoof
GraphDebugMode debugMode

The mode to use for drawing nodes in the sceneview.

See also:
Pathfinding::GraphDebugMode

The path to debug using gizmos.

This is equal to the last path which was calculated, it is used in the editor to draw debug information using gizmos.

float debugRoof = 10000

High value to use for certain debugMode modes.

For example if debugMode is set to G, this value will determine when the node will be totally green.

See also:
debugFloor
const AstarDistribution Distribution = AstarDistribution.WebsiteDownload

Used by the editor to guide the user to the correct place to download updates.

Stack<Node> floodStack

Stack used for flood-filling the graph.

It is saved to minimize memory allocations.

Stack containing all waiting graph update queries.

Add to this stack by using UpdateGraphs

See also:
UpdateGraphs
readonly bool HasPro = true [static]

Used by the editor to show some Pro specific stuff.

Note that setting this to true will not grant you any additional features

Heuristic heuristic = Heuristic.Euclidean

The heuristic to use.

The heuristic, often referred to as 'H' is the estimated cost from a node to the target.

See also:
Pathfinding::Heuristic
float heuristicScale = 1F

The scale of the heuristic.

If a smaller value than 1 is used, the pathfinder will search more nodes (slower). If 0 is used, the pathfinding will be equal to dijkstra's algorithm. If a value larger than 1 is used the pathfinding will (usually) be faster because it expands fewer nodes, but the paths might not longer be optimal

This is the debug string from the last completed path.

The variable will be updated if logPathResults == PathLog.InGame

bool isCalculatingPaths = false [static]

True if the pathfinding is running.

That is, if the CalculatePaths coroutine or the CalculatePathsThreaded thread is running at the moment.

float lastScanTime = 0F

How long time did the last scan take to complete? Used to prevent automatically rescanning the graphs too often (editor only)

The last area index which was used.

Used for the FloodFill function to start flood filling with an unused area.

See also:
FloodFill(Node node)
bool limitGraphUpdates = true

Limit graph updates.

If toggled, graph updates will be executed less often (specified by maxGraphUpdateFreq).

System.Object lockObject = new System.Object () [static]

Synchronises pathfinding thread and Unity thread for graph updates.

When using multithreading, the pathfinding thread will lock on this object when a path request is started and release it when the path has been computed, when updating graphs, the Unity thread will also lock on this object which will cause it to wait until the current path has been computed. This usually results in a break in the pathfinding thread for a few milliseconds, that's why it can be good to limit the number of graph updates per second.

See also:
limitGraphUpdates
PathLog logPathResults = PathLog.Normal

The amount of debugging messages.

Use less debugging to improve performance (a bit) or just to get rid of the Console spamming, use more debugging (heavy) if you want more information about what the pathfinding is doing. InGame will display the latest path log using in game GUI.

float maxFrameTime = 1F

Max number of milliseconds to spend each frame for pathfinding.

At least 100 nodes will be searched each frame (if there are that many to search). When using multithreading this value is quite irrelevant, but do not set it too low since that could add upp to some overhead

float maxGraphUpdateFreq = 0.2F

How often should graphs be updated.

If limitGraphUpdates is true, this defines the minimum amount of seconds between each graph update.

int minAreaSize = 10

Defines the minimum amount of nodes in an area.

If an area has less than this amount of nodes, the area will be flood filled again with the area ID 254, it shouldn't affect pathfinding in any significant way. Can be found in A* Inspector-->Settings-->Min Area Size

bool missedPathQueueIncrement = false [static]

Pop the pathfinding queue once when starting pathfinding.

When the pathfinding coroutine or thread terminates because no path queries were sent, the path queue will have to be popped once before pathfinding is started next time the pathfinding starts

int nextFreePathID = 1 [private]

The next unused Path ID.

Incremented for every call to GetFromPathPool

OnVoidDelegate On65KOverflow [static]

Called when pathID overflows 65536.

The Pathfinding::CleanupPath65K will be added to the queue, and directly after, this callback will be called.

Note:
This callback will be cleared every timed it is called, so if you want to register to it repeatedly, register to it directly on receiving the callback as well.
OnVoidDelegate OnAwakeSettings [static]

Called on Awake before anything else is done.

This is called at the start of the Awake call, right after active has been set, but this is the only thing that has been done.
Use this when you want to set up default settings for an AstarPath component created during runtime.

 //Create a new AstarPath object on Start and apply some default settings
 public void Start () {
    AstarPath.OnAwakeSettings += ApplySettings;
    AstarPath astar = AddComponent<AstarPath>();
 }
 
 public void ApplySettings () {
    //Unregister from the delegate
    AstarPath.OnAwakeSettings -= ApplySettings;
    
    //For example useMultithreading should not be changed after the Awake call
    //so here's the only place to set it if you create the component during runtime
    AstarPath.active.useMultithreading = true;
 }
OnVoidDelegate OnDrawGizmosCallback

Used to enable gizmos in editor scripts.

OnGraphDelegate OnGraphPostScan [static]

Called for each graph after they have been scanned.

All other graphs might not have been scanned yet.

OnGraphDelegate OnGraphPreScan [static]

Called for each graph before they are scanned.

OnScanDelegate OnGraphsUpdated [static]

Called when any graphs are updated.

Register to for example recalculate the path whenever a graph changes.

OnPathDelegate OnGraphUpdate [static]

Used to update the graphs internally.

Do not use this. Use OnGraphsUpdated instead

OnScanDelegate OnLatePostScan [static]

Called after scanning has completed fully.

This is called as the last thing in the Scan function.

OnPathDelegate OnPathPostSearch [static]

Called for each path after searching.

Be carefull when using multithreading since this will be called from a different thread.

OnPathDelegate OnPathPreSearch [static]

Called for each path before searching.

Be carefull when using multithreading since this will be called from a different thread.

OnScanDelegate OnPostScan [static]

Called after scanning.

This is called before applying links and flood-filling the graphs.

OnScanDelegate OnPreScan [static]

Called before starting the scanning.

OnVoidDelegate OnSafeNodeUpdate [static]

Will send a callback when it is safe to update the nodes.

Register to this with RegisterSafeNodeUpdate When it is safe is defined as between the path searches. This callback will only be sent once and is nulled directly after the callback is sent

Warning:
Note that these callbacks are not thread safe when using multithreading, DO NOT call any part of the Unity API from these callbacks except for Debug.Log
PathfindingStatus pathfindingStatus = PathfindingStatus.None [static]
Todo:
Remove
Stack<Path> PathPool [static]

Stack to hold paths waiting to be recycled.

Path pathQueueEnd [static]

Last path added to the pathfinding queue.

Path pathQueueStart [static]

The next path to be computed (or is being computed)

The next path to return using multithreading.

The paths have to be returned using a coroutine running on the same thread as the rest of the game to be able to use the Unity API. This is the next path in the queue to return.

int PathsCompleted = 0 [static]

How many paths has been computed this run.

From application start.
Debugging variable

bool recyclePaths = false

Recycle paths to reduce memory allocations.

This will put paths in a pool to be reused over and over again. If you use this, your scripts using tht paths should copy the vectorPath array and node array (if used) because when the path is recycled, those arrays will be replaced. I.e you should not get data from it using myPath.someVariable (except when you get the path callback) because 'someVariable' might be changed when the path is recycled.

bool scanOnStartup = true

If true, all graphs will be scanned in Awake.

This does not include loading from the cache. If you disable this, you will have to call AstarPath.active.Scan () yourself to enable pathfinding, alternatively you could load a saved graph from a file.

bool showGraphs = false

Shows or hides graph inspectors.

bool showNavGraphs = true

Toggle for showing the gizmo debugging for the graphs in the scene view (editor only).

bool showSearchTree = false

If enabled, nodes will draw a line to their 'parent'.

This will show the search tree in a clear way. This is editor only.

Todo:
Add a showOnlyLastPath flag to indicate whether to draw every node or only the ones visited by the latest path.
bool showUnwalkableNodes = true

Toggle to show unwalkable nodes.

See also:
unwalkableNodeDebugSize
bool stepByStep = true

If enabled, only one node will be searched per search iteration (frame).

Used for debugging

Note:
Might not apply for all path types
int threadTimeoutFrames = 2000 [static]

Max number of iterations in the pathfinding thread without anything to do before aborting the thread.

This is not related to time or game frames in any way, the thread will simply check if there is any work to do every millisecond or something though after half of threadTimeoutFrames it will wait 2 ms between each check instead. After this limit has been reached, the pathfinding thread will abort and will be started again when a new pathfinding call is made

Todo:
Expose in inspector

Size of the red cubes shown in place of unwalkable nodes.

See also:
showUnwalkableNodes
bool useMultithreading = false

Should multithreading be enabled.

Multithreading puts pathfinding in another thread, this is great for performance on 2+ core computers since the framerate will barely be affected by the pathfinding at all. But this can cause strange errors and pathfinding stopping to work if you are not carefull (that is, if you are modifying the pathfinding scripts). For basic usage (not modding the pathfinding core) it should be safe.

A* Pro Feature:
This is an A* Pathfinding Project Pro feature only. This function/class/variable might not exist in the Free version of the A* Pathfinding Project or the functionality might be limited
The Pro version can be bought here

Property Documentation

NavGraph [] graphs [get, set]
System.Type [] graphTypes [get]
System.Version Version [static, get]

The version number for the A* Pathfinding Project.


The documentation for this class was generated from the following file:
 All Classes Functions Variables Enumerations Properties