A* Pathfinding Project  4.1.11
The A* Pathfinding Project for Unity 3D
AstarPath Class Reference

Core component for the A* Pathfinding System. More...

Detailed Description

Core component for the A* Pathfinding System.

This class handles all of the pathfinding system, calculates all paths and stores the info.
This class is a singleton class, meaning there 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.

Examples:
CircuitBoardExample.cs, and MultiTargetFree.cs.

Public Types

enum  AstarDistribution { WebsiteDownload, AssetStore }
 Information about where the package was downloaded. More...
 

Public Member Functions

void AddWorkItem (System.Action callback)
 Add a work item to be processed when pathfinding is paused. More...
 
void AddWorkItem (System.Action< IWorkItemContext > callback)
 Add a work item to be processed when pathfinding is paused. More...
 
void AddWorkItem (AstarWorkItem item)
 Add a work item to be processed when pathfinding is paused. More...
 
void BlockUntilPathQueueBlocked ()
 Blocks until all pathfinding threads are paused and blocked. More...
 
void EnsureValidFloodFill ()
 If a WorkItem needs to have a valid flood fill during execution, call this method to ensure there are no pending flood fills. More...
 
void FloodFill (GraphNode seed)
 Floodfills starting from the specified node. More...
 
void FloodFill (GraphNode seed, uint area)
 Floodfills starting from 'seed' using the specified area. More...
 
void FloodFill ()
 Floodfills all graphs and updates areas for every node. More...
 
void FlushGraphUpdates ()
 Forces graph updates to complete in a single frame. More...
 
void FlushThreadSafeCallbacks ()
 Forces thread safe callbacks to run. More...
 
void FlushWorkItems ()
 Forces work items to complete in a single frame. More...
 
void FlushWorkItems (bool unblockOnComplete, bool block)
 Make sure work items are executed. More...
 
NNInfo GetNearest (Vector3 position)
 Returns the nearest node to a position using the specified NNConstraint. More...
 
NNInfo GetNearest (Vector3 position, NNConstraint constraint)
 Returns the nearest node to a position using the specified NNConstraint. More...
 
NNInfo GetNearest (Vector3 position, NNConstraint constraint, GraphNode hint)
 Returns the nearest node to a position using the specified NNConstraint. More...
 
GraphNode GetNearest (Ray ray)
 Returns the node closest to the ray (slow). More...
 
string [] GetTagNames ()
 Returns tag names. More...
 
PathProcessor.GraphUpdateLock PausePathfinding ()
 Blocks until all pathfinding threads are paused and blocked. More...
 
void QueueGraphUpdates ()
 Will apply queued graph updates as soon as possible, regardless of batchGraphUpdates. More...
 
void QueueWorkItemFloodFill ()
 Call during work items to queue a flood fill. More...
 
void Scan (NavGraph graphToScan)
 Scans a particular graph. More...
 
void Scan (NavGraph[] graphsToScan=null)
 Scans all specified graphs. More...
 
IEnumerable< ProgressScanAsync (NavGraph graphToScan)
 Scans a particular graph asynchronously. More...
 
IEnumerable< ProgressScanAsync (NavGraph[] graphsToScan=null)
 Scans all specified graphs asynchronously. More...
 
void ScanLoop (OnScanStatus statusCallback)
 Scans all graphs. More...
 
void UpdateGraphs (Bounds bounds, float delay)
 Update all graphs within bounds after delay seconds. More...
 
void UpdateGraphs (GraphUpdateObject ob, float delay)
 Update all graphs using the GraphUpdateObject after delay seconds. More...
 
void UpdateGraphs (Bounds bounds)
 Update all graphs within bounds. More...
 
void UpdateGraphs (GraphUpdateObject ob)
 Update all graphs using the GraphUpdateObject. More...
 

Static Public Member Functions

static void BlockUntilCalculated (Path path)
 Blocks until the path has been calculated. More...
 
static int CalculateThreadCount (ThreadCount count)
 Calculates number of threads to use. More...
 
static void FindAstarPath ()
 Used outside of play mode to initialize the AstarPath object even if it has not been selected in the inspector yet. More...
 
static string [] FindTagNames ()
 Tries to find an AstarPath object and return tag names. More...
 
static void RegisterSafeUpdate (System.Action callback, bool threadSafe)
 Will send a callback when it is safe to update nodes. More...
 
static void RegisterSafeUpdate (System.Action callback)
 Will send a callback when it is safe to update nodes. More...
 
static void StartPath (Path path, bool pushToFront=false)
 Adds the path to a queue so that it will be calculated as soon as possible. More...
 
static void WaitForPath (Path path)
 Wait for the specified path to be calculated. More...
 

Public Attributes

AstarData data
 Holds all graph data. More...
 
EuclideanEmbedding euclideanEmbedding = new EuclideanEmbedding()
 Holds settings for heuristic optimization. More...
 
bool showGraphs = false
 Shows or hides graph inspectors. More...
 

Static Public Attributes

static AstarPath active
 Returns the active AstarPath object in the scene. More...
 
static readonly string Branch = "master_Pro"
 Which branch of the A* Pathfinding Project is this release. More...
 
static readonly AstarDistribution Distribution = AstarDistribution.WebsiteDownload
 Used by the editor to guide the user to the correct place to download updates. More...
 
static readonly System.Version Version = new System.Version(4, 1, 11)
 The version number for the A* Pathfinding Project. More...
 

Protected Member Functions

override void Awake ()
 Sets up all needed variables and scans the graphs. More...
 
- Protected Member Functions inherited from VersionedMonoBehaviour
virtual int OnUpgradeSerializedData (int version, bool unityThread)
 Handle serialization backwards compatibility. More...
 

Package Functions

void DestroyNode (GraphNode node)
 Internal method to destroy a given node. More...
 
int GetNewNodeIndex ()
 Returns a new global node index. More...
 
ushort GetNextPathID ()
 Returns the next free path ID. More...
 
void InitializeNode (GraphNode node)
 Initializes temporary path data for a node. More...
 
void VerifyIntegrity ()
 Does simple error checking. More...
 

Package Attributes

readonly PathReturnQueue pathReturnQueue
 Holds all completed paths waiting to be returned to where they were requested. More...
 

Properties

AstarData astarData [get]
 Holds all graph data. More...
 
NavGraph [] graphs [get]
 Shortcut to Pathfinding.AstarData.graphs. More...
 
System.Type [] graphTypes [get]
 See Pathfinding.AstarData. More...
 
bool IsAnyGraphUpdateInProgress [get]
 Returns if any graph updates are being calculated right now. More...
 
bool IsAnyGraphUpdateQueued [get]
 Returns if any graph updates are waiting to be applied. More...
 
bool IsAnyGraphUpdatesQueued [get]
 Returns if any graph updates are waiting to be applied. More...
 
bool IsAnyWorkItemInProgress [get]
 Returns if any work items are in progress right now. More...
 
bool IsInsideWorkItem [get]
 Returns if this code is currently being exectuted inside a work item. More...
 
bool isScanning [get, private set]
 Set while any graphs are being scanned. More...
 
bool IsUsingMultithreading [get]
 Returns whether or not multithreading is used. More...
 
int NumParallelThreads [get]
 Number of parallel pathfinders. More...
 

Private Member Functions

 AstarPath ()
 
IEnumerator DelayedGraphUpdate ()
 Waits a moment with updating graphs. More...
 
void InitializeAstarData ()
 Initializes the AstarData class. More...
 
void InitializePathProcessor ()
 Initializes the pathProcessor field. More...
 
void InitializeProfiler ()
 Calls AstarProfiler.InitializeFastProfile. More...
 
void LogPathResults (Path path)
 Prints path results to the log. More...
 
void OnApplicationQuit ()
 Terminates pathfinding threads when the application quits. More...
 
void OnDestroy ()
 Clears up variables and other stuff, destroys graphs. More...
 
void OnDisable ()
 Cleans up meshes to avoid memory leaks. More...
 
void OnDrawGizmos ()
 Calls OnDrawGizmos on graph generators. More...
 
void OnGUI ()
 Draws the InGame debugging (if enabled), also shows the fps if 'L' is pressed down. More...
 
PathProcessor.GraphUpdateLock PausePathfindingSoon ()
 Blocks the path queue so that e.g work items can be performed. More...
 
void PerformBlockingActions (bool force=false)
 
void RecalculateDebugLimits ()
 
IEnumerable< ProgressScanGraph (NavGraph graph)
 
void Update ()
 Checks if any work items need to be executed then runs pathfinding for a while (if not using multithreading because then the calculation happens in other threads) and then returns any calculated paths to the scripts that requested them. More...
 
IEnumerator UpdateGraphsInternal (GraphUpdateObject ob, float delay)
 Update all graphs using the GraphUpdateObject after delay seconds. More...
 

Private Attributes

Pathfinding.Util.RetainedGizmos gizmos = new Pathfinding.Util.RetainedGizmos()
 
bool graphUpdateRoutineRunning = false
 
readonly GraphUpdateProcessor graphUpdates
 Processes graph updates. More...
 
bool graphUpdatesWorkItemAdded = false
 Makes sure QueueGraphUpdates will not queue multiple graph update orders. More...
 
bool isScanningBacking
 Backing field for isScanning. More...
 
float lastGraphUpdate = -9999F
 Time the last graph update was done. More...
 
ushort nextFreePathID = 1
 The next unused Path ID. More...
 
PathProcessor pathProcessor
 Holds all paths waiting to be calculated and calculates them. More...
 
PathProcessor.GraphUpdateLock workItemLock
 Held if any work items are currently queued. More...
 
readonly WorkItemProcessor workItems
 Processes work items. More...
 

Static Private Attributes

static int waitForPathDepth = 0
 

Inspector - Debug

bool showNavGraphs = true
 Toggle for showing the gizmo debugging for the graphs in the scene view (editor only). More...
 
bool showUnwalkableNodes = true
 Toggle to show unwalkable nodes. More...
 
GraphDebugMode debugMode
 The mode to use for drawing nodes in the sceneview. More...
 
float debugFloor = 0
 Low value to use for certain debugMode modes. More...
 
float debugRoof = 20000
 High value to use for certain debugMode modes. More...
 
bool manualDebugFloorRoof = false
 If set, the debugFloor and debugRoof values will not be automatically recalculated. More...
 
bool showSearchTree = false
 If enabled, nodes will draw a line to their 'parent'. More...
 
float unwalkableNodeDebugSize = 0.3F
 Size of the red cubes shown in place of unwalkable nodes. More...
 
PathLog logPathResults = PathLog.Normal
 The amount of debugging messages. More...
 

Inspector - Settings

float maxNearestNodeDistanceSqr [get]
 Max Nearest Node Distance Squared. More...
 
bool limitGraphUpdates [get, set]
 Batch graph updates. More...
 
float maxGraphUpdateFreq [get, set]
 Limit for how often should graphs be updated. More...
 
float maxNearestNodeDistance = 100
 Maximum distance to search for nodes. More...
 
bool scanOnStartup = true
 If true, all graphs will be scanned during Awake. More...
 
bool fullGetNearestSearch = false
 Do a full GetNearest search for all graphs. More...
 
bool prioritizeGraphs = false
 Prioritize graphs. More...
 
float prioritizeGraphsLimit = 1F
 Distance limit for prioritizeGraphs. More...
 
AstarColor colorSettings
 Reference to the color settings for this AstarPath object. More...
 
Heuristic heuristic = Heuristic.Euclidean
 The distance function to use as a heuristic. More...
 
float heuristicScale = 1F
 The scale of the heuristic. More...
 
ThreadCount threadCount = ThreadCount.One
 Number of pathfinding threads to use. More...
 
float maxFrameTime = 1F
 Max number of milliseconds to spend each frame for pathfinding. More...
 
int minAreaSize = 0
 Defines the minimum amount of nodes in an area. More...
 
bool batchGraphUpdates = false
 Throttle graph updates and batch them to improve performance. More...
 
float graphUpdateBatchingInterval = 0.2F
 Minimum number of seconds between each batch of graph updates. More...
 
string [] tagNames = null
 Stored tag names. More...
 

Debug Members

float lastScanTime [get, private set]
 The time it took for the last call to Scan() to complete. More...
 
PathHandler debugPathData
 The path to debug using gizmos. More...
 
ushort debugPathID
 The path ID to debug using gizmos. More...
 
string inGameDebugPath
 Debug string from the last completed path. More...
 

Callbacks

static System.Action OnAwakeSettings
 Called on Awake before anything else is done. More...
 
static OnGraphDelegate OnGraphPreScan
 Called for each graph before they are scanned. More...
 
static OnGraphDelegate OnGraphPostScan
 Called for each graph after they have been scanned. More...
 
static OnPathDelegate OnPathPreSearch
 Called for each path before searching. More...
 
static OnPathDelegate OnPathPostSearch
 Called for each path after searching. More...
 
static OnScanDelegate OnPreScan
 Called before starting the scanning. More...
 
static OnScanDelegate OnPostScan
 Called after scanning. More...
 
static OnScanDelegate OnLatePostScan
 Called after scanning has completed fully. More...
 
static OnScanDelegate OnGraphsUpdated
 Called when any graphs are updated. More...
 
static System.Action On65KOverflow
 Called when pathID overflows 65536 and resets back to zero. More...
 
System.Action OnGraphsWillBeUpdated
 
System.Action OnGraphsWillBeUpdated2
 

Member Enumeration Documentation

◆ AstarDistribution

enum AstarDistribution
strong

Information about where the package was downloaded.

Enumerator
WebsiteDownload 
AssetStore 

Constructor & Destructor Documentation

◆ AstarPath()

AstarPath ( )
private

Member Function Documentation

◆ AddWorkItem() [1/3]

void AddWorkItem ( System.Action  callback)

Add a work item to be processed when pathfinding is paused.

Convenience method that is equivalent to

AddWorkItem(new AstarWorkItem(callback));
See also
AddWorkItem(AstarWorkItem)

◆ AddWorkItem() [2/3]

void AddWorkItem ( System.Action< IWorkItemContext callback)

Add a work item to be processed when pathfinding is paused.

Convenience method that is equivalent to

AddWorkItem(new AstarWorkItem(callback));
See also
AddWorkItem(AstarWorkItem)

◆ AddWorkItem() [3/3]

void AddWorkItem ( AstarWorkItem  item)

Add a work item to be processed when pathfinding is paused.

The work item will be executed when it is safe to update nodes. This is defined as between the path searches. When using more threads than one, calling this often might decrease pathfinding performance due to a lot of idling in the threads. Not performance as in it will use much CPU power, but performance as in the number of paths per second will probably go down (though your framerate might actually increase a tiny bit).

You should only call this function from the main unity thread (i.e normal game code).

AstarPath.active.AddWorkItem(new AstarWorkItem(ctx => {
var node = AstarPath.active.GetNearest(transform.position).node;
node.Walkable = false;
ctx.QueueFloodFill();
}));
// Safe to update graphs here
var node = AstarPath.active.GetNearest(transform.position).node;
node.position = (Int3)transform.position;
});
See also
FlushWorkItems

◆ Awake()

override void Awake ( )
protectedvirtual

Sets up all needed variables and scans the graphs.

Calls Initialize, starts the ReturnPaths coroutine and scans all graphs. Also starts threads if using multithreading

See also
OnAwakeSettings

Reimplemented from VersionedMonoBehaviour.

◆ BlockUntilCalculated()

static void BlockUntilCalculated ( Path  path)
static

Blocks until the path has been calculated.

Parameters
pathThe path to wait for. The path must be started, otherwise an exception will be thrown.

Normally it takes a few frames for a path to be calculated and returned. This function will ensure that the path will be calculated when this function returns and that the callback for that path has been called.

If requesting a lot of paths in one go and waiting for the last one to complete, it will calculate most of the paths in the queue (only most if using multithreading, all if not using multithreading).

Use this function only if you really need to. There is a point to spreading path calculations out over several frames. It smoothes out the framerate and makes sure requesting a large number of paths at the same time does not cause lag.

Note
Graph updates and other callbacks might get called during the execution of this function.

When the pathfinder is shutting down. I.e in OnDestroy, this function will not do anything.

Exceptions
Exceptionif pathfinding is not initialized properly for this scene (most likely no AstarPath object exists) or if the path has not been started yet. Also throws an exception if critical errors occur such as when the pathfinding threads have crashed (which should not happen in normal cases). This prevents an infinite loop while waiting for the path.
See also
Pathfinding.Path.WaitForPath
Pathfinding.Path.BlockUntilCalculated

◆ BlockUntilPathQueueBlocked()

void BlockUntilPathQueueBlocked ( )

Blocks until all pathfinding threads are paused and blocked.

Deprecated:
Use PausePathfinding instead. Make sure to call Release on the returned lock.

◆ CalculateThreadCount()

static int CalculateThreadCount ( ThreadCount  count)
static

Calculates number of threads to use.

If count is not Automatic, simply returns count casted to an int.

Returns
An int specifying how many threads to use, 0 means a coroutine should be used for pathfinding instead of a separate thread.

If count is set to Automatic it will return a value based on the number of processors and memory for the current system. If memory is <= 512MB or logical cores are <= 1, it will return 0. If memory is <= 1024 it will clamp threads to max 2. Otherwise it will return the number of logical cores clamped to 6.

When running on WebGL this method always returns 0

◆ DelayedGraphUpdate()

IEnumerator DelayedGraphUpdate ( )
private

Waits a moment with updating graphs.

If batchGraphUpdates is set, we want to keep some space between them to let pathfinding threads running and then calculate all queued calls at once

◆ DestroyNode()

void DestroyNode ( GraphNode  node)
package

Internal method to destroy a given node.

This is to be called after the node has been disconnected from the graph so that it cannot be reached from any other nodes. It should only be called during graph updates, that is when the pathfinding threads are either not running or paused.

Warning
This method should not be called by user code. It is used internally by the system.

◆ EnsureValidFloodFill()

void EnsureValidFloodFill ( )

If a WorkItem needs to have a valid flood fill during execution, call this method to ensure there are no pending flood fills.

Deprecated:
This method has been moved. Use the method on the context object that can be sent with work item delegates instead
AstarPath.active.AddWorkItem(new AstarWorkItem(ctx => {
var node = AstarPath.active.GetNearest(transform.position).node;
node.Walkable = false;
ctx.QueueFloodFill();
}));
See also
Pathfinding.IWorkItemContext

◆ FindAstarPath()

static void FindAstarPath ( )
static

Used outside of play mode to initialize the AstarPath object even if it has not been selected in the inspector yet.

This will set the active property and deserialize all graphs.

This is useful if you want to do changes to the graphs in the editor outside of play mode, but cannot be sure that the graphs have been deserialized yet. In play mode this method does nothing.

◆ FindTagNames()

static string [] FindTagNames ( )
static

Tries to find an AstarPath object and return tag names.

If an AstarPath object cannot be found, it returns an array of length 1 with an error message.

See also
AstarPath.GetTagNames

◆ FloodFill() [1/3]

void FloodFill ( GraphNode  seed)

Floodfills starting from the specified node.

◆ FloodFill() [2/3]

void FloodFill ( GraphNode  seed,
uint  area 
)

Floodfills starting from 'seed' using the specified area.

◆ FloodFill() [3/3]

void FloodFill ( )

Floodfills all graphs and updates areas for every node.

The different colored areas that you see in the scene view when looking at graphs are called just 'areas', this method calculates which nodes are in what areas.

See also
Pathfinding.Node.area

◆ FlushGraphUpdates()

void FlushGraphUpdates ( )

Forces graph updates to complete in a single frame.

This will force the pathfinding threads to finish calculating the path they are currently calculating (if any) and then pause. When all threads have paused, graph updates will be performed.

Warning
Using this very often (many times per second) can reduce your fps due to a lot of threads waiting for one another. But you probably wont have to worry about that.
Note
This is almost identical to FlushWorkItems, but added for more descriptive name. This function will also override any time limit delays for graph updates. This is because graph updates are implemented using work items. So calling this function will also execute any other work items (if any are queued).

Will not do anything if there are no graph updates queued (not even execute other work items).

◆ FlushThreadSafeCallbacks()

void FlushThreadSafeCallbacks ( )

Forces thread safe callbacks to run.

Deprecated:
Use FlushWorkItems instead

◆ FlushWorkItems() [1/2]

void FlushWorkItems ( )

Forces work items to complete in a single frame.

This will force all work items to run immidiately. This will force the pathfinding threads to finish calculating the path they are currently calculating (if any) and then pause. When all threads have paused, work items will be executed (which can be e.g graph updates).

Warning
Using this very often (many times per second) can reduce your fps due to a lot of threads waiting for one another. But you probably wont have to worry about that
Note
This is almost (note almost) identical to FlushGraphUpdates, but added for more descriptive name.

Will not do anything if there are no queued work items waiting to run.

◆ FlushWorkItems() [2/2]

void FlushWorkItems ( bool  unblockOnComplete,
bool  block 
)

Make sure work items are executed.

Parameters
unblockOnCompleteIf true, pathfinding will be allowed to start running immediately after completing all work items.
blockIf true, work items that usually take more than one frame to complete will be forced to complete during this call. If false, then after this call there might still be work left to do.
See also
AddWorkItem
Deprecated:
Use FlushWorkItems() instead.

◆ GetNearest() [1/4]

NNInfo GetNearest ( Vector3  position)

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.
Using the NNConstraint.None constraint.

// Find the closest node to this GameObject's position
GraphNode node = AstarPath.active.GetNearest(transform.position).node;
if (node.Walkable) {
// Yay, the node is walkable, we can place a tower here or something
}
See also
Pathfinding.NNConstraint

◆ GetNearest() [2/4]

NNInfo GetNearest ( Vector3  position,
NNConstraint  constraint 
)

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. The NNConstraint can be used to specify constraints on which nodes can be chosen such as only picking walkable nodes.

GraphNode node = AstarPath.active.GetNearest(transform.position, NNConstraint.Default).node;
var constraint = NNConstraint.None;
// Constrain the search to walkable nodes only
constraint.constrainWalkability = true;
constraint.walkable = true;
// Constrain the search to only nodes with tag 3 or tag 5
// The 'tags' field is a bitmask
constraint.constrainTags = true;
constraint.tags = (1 << 3) | (1 << 5);
var info = AstarPath.active.GetNearest(transform.position, constraint);
var node = info.node;
var closestPoint = info.position;
See also
Pathfinding.NNConstraint

◆ GetNearest() [3/4]

NNInfo GetNearest ( Vector3  position,
NNConstraint  constraint,
GraphNode  hint 
)

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. The NNConstraint can be used to specify constraints on which nodes can be chosen such as only picking walkable nodes.

See also
Pathfinding.NNConstraint

◆ GetNearest() [4/4]

GraphNode GetNearest ( Ray  ray)

Returns the node closest to the ray (slow).

Warning
This function is brute-force and very slow, use with caution

◆ GetNewNodeIndex()

int GetNewNodeIndex ( )
package

Returns a new global node index.

Warning
This method should not be called directly. It is used by the GraphNode constructor.

◆ GetNextPathID()

ushort GetNextPathID ( )
package

Returns the next free path ID.

◆ GetTagNames()

string [] GetTagNames ( )

Returns tag names.

Makes sure that the tag names array is not null and of length 32. If it is null or not of length 32, it creates a new array and fills it with 0,1,2,3,4 etc...

See also
AstarPath.FindTagNames

◆ InitializeAstarData()

void InitializeAstarData ( )
private

Initializes the AstarData class.

Searches for graph types, calls Awake on data and on all graphs

See also
AstarData.FindGraphTypes

◆ InitializeNode()

void InitializeNode ( GraphNode  node)
package

Initializes temporary path data for a node.

Warning
This method should not be called directly. It is used by the GraphNode constructor.

◆ InitializePathProcessor()

void InitializePathProcessor ( )
private

Initializes the pathProcessor field.

◆ InitializeProfiler()

void InitializeProfiler ( )
private

Calls AstarProfiler.InitializeFastProfile.

◆ LogPathResults()

void LogPathResults ( Path  path)
private

Prints path results to the log.

What it prints can be controled using logPathResults.

See also
logPathResults
PathLog
Pathfinding.Path.DebugString

◆ OnApplicationQuit()

void OnApplicationQuit ( )
private

Terminates pathfinding threads when the application quits.

◆ OnDestroy()

void OnDestroy ( )
private

Clears up variables and other stuff, destroys graphs.

Note that when destroying an AstarPath object, all static variables such as callbacks will be cleared.

◆ OnDisable()

void OnDisable ( )
private

Cleans up meshes to avoid memory leaks.

◆ OnDrawGizmos()

void OnDrawGizmos ( )
private

Calls OnDrawGizmos on graph generators.

◆ OnGUI()

void OnGUI ( )
private

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

See also
logPathResults PathLog

◆ PausePathfinding()

PathProcessor.GraphUpdateLock PausePathfinding ( )

Blocks until all pathfinding threads are paused and blocked.

var graphLock = AstarPath.active.PausePathfinding();
// Here we can modify the graphs safely. For example by adding a new node to a point graph
var node = AstarPath.active.data.pointGraph.AddNode((Int3) new Vector3(3, 1, 4));
// Allow pathfinding to resume
graphLock.Release();
Returns
A lock object. You need to call Release on that object to allow pathfinding to resume.
Note
In most cases this should not be called from user code. Use the AddWorkItem method instead.
See also
AddWorkItem

◆ PausePathfindingSoon()

PathProcessor.GraphUpdateLock PausePathfindingSoon ( )
private

Blocks the path queue so that e.g work items can be performed.

◆ PerformBlockingActions()

void PerformBlockingActions ( bool  force = false)
private

◆ QueueGraphUpdates()

void QueueGraphUpdates ( )

Will apply queued graph updates as soon as possible, regardless of batchGraphUpdates.

Calling this multiple times will not create multiple callbacks. This function is useful if you are limiting graph updates, but you want a specific graph update to be applied as soon as possible regardless of the time limit. Note that this does not block until the updates are done, it merely bypasses the batchGraphUpdates time limit.

See also
FlushGraphUpdates

◆ QueueWorkItemFloodFill()

void QueueWorkItemFloodFill ( )

Call during work items to queue a flood fill.

Deprecated:
This method has been moved. Use the method on the context object that can be sent with work item delegates instead
AstarPath.active.AddWorkItem(new AstarWorkItem(ctx => {
var node = AstarPath.active.GetNearest(transform.position).node;
node.Walkable = false;
ctx.QueueFloodFill();
}));
See also
Pathfinding.IWorkItemContext

◆ RecalculateDebugLimits()

void RecalculateDebugLimits ( )
private

◆ RegisterSafeUpdate() [1/2]

static void RegisterSafeUpdate ( System.Action  callback,
bool  threadSafe 
)
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. When using more threads than one, calling this often might decrease pathfinding performance due to a lot of idling in the threads. Not performance as in it will use much CPU power, but performance as in the number of paths per second will probably go down (though your framerate might actually increase a tiny bit)

You should only call this function from the main unity thread (i.e normal game code).

Note
The threadSafe parameter has been deprecated
Deprecated:

◆ RegisterSafeUpdate() [2/2]

static void RegisterSafeUpdate ( System.Action  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. When using more threads than one, calling this often might decrease pathfinding performance due to a lot of idling in the threads. Not performance as in it will use much CPU power, but performance as in the number of paths per second will probably go down (though your framerate might actually increase a tiny bit)

You should only call this function from the main unity thread (i.e normal game code).

Version
Since version 4.0 this is equivalent to AddWorkItem(new AstarWorkItem(callback)). Previously the callbacks added using this method would not be ordered with respect to other work items, so they could be executed before other work items or after them.
Deprecated:
Use AddWorkItem(System.Action) instead. Note the slight change in behavior (mentioned above).

◆ Scan() [1/2]

void Scan ( NavGraph  graphToScan)

Scans a particular graph.

Calling this method will recalculate the specified graph. This method is pretty slow (depending on graph type and graph complexity of course), so it is advisable to use smaller graph updates whenever possible.

// Recalculate all graphs
// Recalculate only the first grid graph
var graphToScan = AstarPath.active.data.gridGraph;
AstarPath.active.Scan(graphToScan);
// Recalculate only the first and third graphs
var graphsToScan = new [] { AstarPath.active.data.graphs[0], AstarPath.active.data.graphs[2] };
AstarPath.active.Scan(graphsToScan);
See also
Graph Updates during Runtime
ScanAsync

◆ Scan() [2/2]

void Scan ( NavGraph []  graphsToScan = null)

Scans all specified graphs.

Parameters
graphsToScanThe graphs to scan. If this parameter is null then all graphs will be scanned

Calling this method will recalculate all specified graphs or all graphs if the graphsToScan parameter is null. This method is pretty slow (depending on graph type and graph complexity of course), so it is advisable to use smaller graph updates whenever possible.

// Recalculate all graphs
// Recalculate only the first grid graph
var graphToScan = AstarPath.active.data.gridGraph;
AstarPath.active.Scan(graphToScan);
// Recalculate only the first and third graphs
var graphsToScan = new [] { AstarPath.active.data.graphs[0], AstarPath.active.data.graphs[2] };
AstarPath.active.Scan(graphsToScan);
See also
Graph Updates during Runtime
ScanAsync

◆ ScanAsync() [1/2]

IEnumerable<Progress> ScanAsync ( NavGraph  graphToScan)

Scans a particular graph asynchronously.

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

foreach (Progress progress in AstarPath.active.ScanAsync()) {
Debug.Log("Scanning... " + progress.description + " - " + (progress.progress*100).ToString("0") + "%");
}

You can scan graphs asyncronously by yielding when you loop through the progress. Note that this does not guarantee a good framerate, but it will allow you to at least show a progress bar during scanning.

IEnumerator Start () {
foreach (Progress progress in AstarPath.active.ScanAsync()) {
Debug.Log("Scanning... " + progress.description + " - " + (progress.progress*100).ToString("0") + "%");
yield return null;
}
}
See also
Scan

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

◆ ScanAsync() [2/2]

IEnumerable<Progress> ScanAsync ( NavGraph []  graphsToScan = null)

Scans all specified graphs asynchronously.

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

Parameters
graphsToScanThe graphs to scan. If this parameter is null then all graphs will be scanned
foreach (Progress progress in AstarPath.active.ScanAsync()) {
Debug.Log("Scanning... " + progress.description + " - " + (progress.progress*100).ToString("0") + "%");
}

You can scan graphs asyncronously by yielding when you loop through the progress. Note that this does not guarantee a good framerate, but it will allow you to at least show a progress bar during scanning.

IEnumerator Start () {
foreach (Progress progress in AstarPath.active.ScanAsync()) {
Debug.Log("Scanning... " + progress.description + " - " + (progress.progress*100).ToString("0") + "%");
yield return null;
}
}
See also
Scan

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

◆ ScanGraph()

IEnumerable<Progress> ScanGraph ( NavGraph  graph)
private

◆ ScanLoop()

void ScanLoop ( OnScanStatus  statusCallback)

Scans all graphs.

Deprecated:
Use Scan or ScanAsync instead
See also
Scan

◆ StartPath()

static void StartPath ( Path  path,
bool  pushToFront = false 
)
static

Adds the path to a queue so that it will be calculated as soon as possible.

The callback specified when constructing the path will be called when the path has been calculated. Usually you should use the Seeker component instead of calling this function directly.

Parameters
pathThe path that should be enqueued.
pushToFrontIf true, the path will be pushed to the front of the queue, bypassing all waiting paths and making it the next path to be calculated. This can be useful if you have a path which you want to prioritize over all others. Be careful to not overuse it though. If too many paths are put in the front of the queue often, this can lead to normal paths having to wait a very long time before being calculated.
Examples:
CircuitBoardExample.cs, and MultiTargetFree.cs.

◆ Update()

void Update ( )
private

Checks if any work items need to be executed then runs pathfinding for a while (if not using multithreading because then the calculation happens in other threads) and then returns any calculated paths to the scripts that requested them.

See also
PerformBlockingActions
PathProcessor.TickNonMultithreaded
PathReturnQueue.ReturnPaths

◆ UpdateGraphs() [1/4]

void UpdateGraphs ( Bounds  bounds,
float  delay 
)

Update all graphs within bounds after delay seconds.

The graphs will be updated as soon as possible.

See also
FlushGraphUpdates
batchGraphUpdates
Graph Updates during Runtime

◆ UpdateGraphs() [2/4]

void UpdateGraphs ( GraphUpdateObject  ob,
float  delay 
)

Update all graphs using the GraphUpdateObject after delay seconds.

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

See also
FlushGraphUpdates
batchGraphUpdates
Graph Updates during Runtime

◆ UpdateGraphs() [3/4]

void UpdateGraphs ( Bounds  bounds)

Update all graphs within bounds.

The graphs will be updated as soon as possible.

This is equivalent to

UpdateGraphs(new GraphUpdateObject(bounds));
See also
FlushGraphUpdates
batchGraphUpdates
Graph Updates during Runtime

◆ UpdateGraphs() [4/4]

void UpdateGraphs ( GraphUpdateObject  ob)

Update all graphs using the GraphUpdateObject.

This can be used to, e.g make all nodes in a region unwalkable, or set them to a higher penalty. The graphs will be updated as soon as possible (with respect to batchGraphUpdates)

See also
FlushGraphUpdates
batchGraphUpdates
Graph Updates during Runtime

◆ UpdateGraphsInternal()

IEnumerator UpdateGraphsInternal ( GraphUpdateObject  ob,
float  delay 
)
private

Update all graphs using the GraphUpdateObject after delay seconds.

◆ VerifyIntegrity()

void VerifyIntegrity ( )
package

Does simple error checking.

◆ WaitForPath()

static void WaitForPath ( Path  path)
static

Wait for the specified path to be calculated.

Normally it takes a few frames for a path to get calculated and returned.

Deprecated:
This method has been renamed to BlockUntilCalculated.

Member Data Documentation

◆ active

AstarPath active
static

Returns the active AstarPath object in the scene.

Note
This is only set if the AstarPath object has been initialized (which happens in Awake).

◆ batchGraphUpdates

bool batchGraphUpdates = false

Throttle graph updates and batch them to improve performance.

If toggled, graph updates will batched and executed less often (specified by graphUpdateBatchingInterval).

This can have a positive impact on pathfinding throughput since the pathfinding threads do not need to be stopped as often, and it reduces the overhead per graph update. All graph updates are still applied however, they are just batched together so that more of them are applied at the same time.

However do not use this if you want minimal latency between a graph update being requested and it being applied.

This only applies to graph updates requested using the UpdateGraphs method. Not those requested using RegisterSafeUpdate or AddWorkItem.

See also
Graph Updates during Runtime

◆ Branch

readonly string Branch = "master_Pro"
static

Which branch of the A* Pathfinding Project is this release.

Used when checking for updates so that users of the development versions can get notifications of development updates.

◆ colorSettings

AstarColor colorSettings

Reference to the color settings for this AstarPath object.

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

◆ data

AstarData data

Holds all graph data.

◆ debugFloor

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 completely red.

Note
Only relevant in the editor
See also
debugRoof
debugMode

◆ debugMode

GraphDebugMode debugMode

The mode to use for drawing nodes in the sceneview.

Note
Only relevant in the editor
See also
Pathfinding.GraphDebugMode

◆ debugPathData

PathHandler debugPathData

The path to debug using gizmos.

This is the path handler used to calculate the last path. It is used in the editor to draw debug information using gizmos.

◆ debugPathID

ushort debugPathID

The path ID to debug using gizmos.

◆ debugRoof

float debugRoof = 20000

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 completely green.

For the penalty debug mode, the nodes will be colored green when they have a penalty less than debugFloor and red when their penalty is greater or equal to this value and something between red and green otherwise.

Note
Only relevant in the editor
See also
debugFloor
debugMode

◆ Distribution

readonly AstarDistribution Distribution = AstarDistribution.WebsiteDownload
static

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

◆ euclideanEmbedding

EuclideanEmbedding euclideanEmbedding = new EuclideanEmbedding()

Holds settings for heuristic optimization.

See also
heuristic-opt

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

◆ fullGetNearestSearch

bool fullGetNearestSearch = false

Do a full GetNearest search for all graphs.

Additional searches will normally only be done on the graph which in the first fast search seemed to have the closest node. With this setting on, additional searches will be done on all graphs since the first check is not always completely accurate.
More technically: GetNearestForce on all graphs will be called if true, otherwise only on the one graph which's GetNearest search returned the best node.
Usually faster when disabled, but higher quality searches when enabled. When using a a navmesh or recast graph, for best quality, this setting should be combined with the Pathfinding.NavMeshGraph.accurateNearestNode setting set to true.

Note
For the PointGraph this setting doesn't matter much as it has only one search mode.

◆ gizmos

◆ graphUpdateBatchingInterval

float graphUpdateBatchingInterval = 0.2F

Minimum number of seconds between each batch of graph updates.

If batchGraphUpdates is true, this defines the minimum number of seconds between each batch of graph updates.

This can have a positive impact on pathfinding throughput since the pathfinding threads do not need to be stopped as often, and it reduces the overhead per graph update. All graph updates are still applied however, they are just batched together so that more of them are applied at the same time.

Do not use this if you want minimal latency between a graph update being requested and it being applied.

This only applies to graph updates requested using the UpdateGraphs method. Not those requested using RegisterSafeUpdate or AddWorkItem.

See also
Graph Updates during Runtime

◆ graphUpdateRoutineRunning

bool graphUpdateRoutineRunning = false
private

◆ graphUpdates

readonly GraphUpdateProcessor graphUpdates
private

Processes graph updates.

◆ graphUpdatesWorkItemAdded

bool graphUpdatesWorkItemAdded = false
private

Makes sure QueueGraphUpdates will not queue multiple graph update orders.

◆ heuristic

Heuristic heuristic = Heuristic.Euclidean

The distance function to use as a heuristic.

The heuristic, often referred to as just 'H' is the estimated cost from a node to the target. Different heuristics affect how the path picks which one to follow from multiple possible with the same length

See also
Pathfinding.Heuristic for more details and descriptions of the different modes.
Wikipedia: Admissible heuristic
Wikipedia: A* search algorithm
Wikipedia: Dijkstra's Algorithm

◆ heuristicScale

float heuristicScale = 1F

The scale of the heuristic.

If a value lower than 1 is used, the pathfinder will search more nodes (slower). If 0 is used, the pathfinding algorithm will be reduced to dijkstra's algorithm. This is equivalent to setting heuristic to None. If a value larger than 1 is used the pathfinding will (usually) be faster because it expands fewer nodes, but the paths may no longer be the optimal (i.e the shortest possible paths).

Usually you should leave this to the default value of 1.

See also
https://en.wikipedia.org/wiki/Admissible_heuristic
https://en.wikipedia.org/wiki/A*_search_algorithm
https://en.wikipedia.org/wiki/Dijkstra%27s_algorithm

◆ inGameDebugPath

string inGameDebugPath
private

Debug string from the last completed path.

Will be updated if logPathResults == PathLog.InGame

◆ isScanningBacking

bool isScanningBacking
private

Backing field for isScanning.

Cannot use an auto-property because they cannot be marked with System.NonSerialized.

◆ lastGraphUpdate

float lastGraphUpdate = -9999F
private

Time the last graph update was done.

Used to group together frequent graph updates to batches

◆ logPathResults

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 scripts are doing. The InGame option will display the latest path log using in-game GUI.

◆ manualDebugFloorRoof

bool manualDebugFloorRoof = false

If set, the debugFloor and debugRoof values will not be automatically recalculated.

Note
Only relevant in the editor

◆ maxFrameTime

float maxFrameTime = 1F

Max number of milliseconds to spend each frame for pathfinding.

At least 500 nodes will be searched each frame (if there are that many to search). When using multithreading this value is irrelevant.

◆ maxNearestNodeDistance

float maxNearestNodeDistance = 100

Maximum distance to search for nodes.

When searching for the nearest node to a point, this is the limit (in world units) for how far away it is allowed to be.

This is relevant if you try to request a path to a point that cannot be reached and it thus has to search for the closest node to that point which can be reached (which might be far away). If it cannot find a node within this distance then the path will fail.

See also
Pathfinding.NNConstraint.constrainDistance

◆ minAreaSize

int minAreaSize = 0

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 GraphNode.MaxAreaIndex-1, it shouldn't affect pathfinding in any significant way.
If you want to be able to separate areas from one another for some reason (for example to do a fast check to see if a path is at all possible) you should set this variable to 0.

Version
Since version 3.6, this variable should in most cases be set to 0 since the max number of area indices available has been greatly increased.
Deprecated:
This is handled automatically now

◆ nextFreePathID

ushort nextFreePathID = 1
private

The next unused Path ID.

Incremented for every call to GetNextPathID

◆ On65KOverflow

System.Action On65KOverflow
static

Called when pathID overflows 65536 and resets back to zero.

Note
This callback will be cleared every time it is called, so if you want to register to it repeatedly, register to it directly on receiving the callback as well.

◆ OnAwakeSettings

System.Action 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 since some settings can only be changed in Awake (such as multithreading related stuff)

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

◆ OnGraphPostScan

OnGraphDelegate OnGraphPostScan
static

Called for each graph after they have been scanned.

All other graphs might not have been scanned yet.

◆ OnGraphPreScan

OnGraphDelegate OnGraphPreScan
static

Called for each graph before they are scanned.

◆ OnGraphsUpdated

OnScanDelegate OnGraphsUpdated
static

Called when any graphs are updated.

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

◆ OnGraphsWillBeUpdated

System.Action OnGraphsWillBeUpdated

◆ OnGraphsWillBeUpdated2

System.Action OnGraphsWillBeUpdated2

◆ OnLatePostScan

OnScanDelegate OnLatePostScan
static

Called after scanning has completed fully.

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

◆ OnPathPostSearch

OnPathDelegate OnPathPostSearch
static

Called for each path after searching.

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

◆ OnPathPreSearch

OnPathDelegate OnPathPreSearch
static

Called for each path before searching.

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

◆ OnPostScan

OnScanDelegate OnPostScan
static

Called after scanning.

This is called before applying links, flood-filling the graphs and other post processing.

◆ OnPreScan

OnScanDelegate OnPreScan
static

Called before starting the scanning.

◆ pathProcessor

PathProcessor pathProcessor
private

Holds all paths waiting to be calculated and calculates them.

◆ pathReturnQueue

readonly PathReturnQueue pathReturnQueue
package

Holds all completed paths waiting to be returned to where they were requested.

◆ prioritizeGraphs

bool prioritizeGraphs = false

Prioritize graphs.

Graphs will be prioritized based on their order in the inspector. The first graph which has a node closer than prioritizeGraphsLimit will be chosen instead of searching all graphs.

◆ prioritizeGraphsLimit

float prioritizeGraphsLimit = 1F

Distance limit for prioritizeGraphs.

See also
prioritizeGraphs

◆ scanOnStartup

bool scanOnStartup = true

If true, all graphs will be scanned during 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.

See also
Scan
ScanAsync

◆ showGraphs

bool showGraphs = false

Shows or hides graph inspectors.

Used internally by the editor

◆ showNavGraphs

bool showNavGraphs = true

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

◆ showSearchTree

bool showSearchTree = false

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

This will show the search tree for the latest path.

Note
Only relevant in the editor
Todo:
Add a showOnlyLastPath flag to indicate whether to draw every node or only the ones visited by the latest path.

◆ showUnwalkableNodes

bool showUnwalkableNodes = true

Toggle to show unwalkable nodes.

Note
Only relevant in the editor
See also
unwalkableNodeDebugSize

◆ tagNames

string [] tagNames = null
protected

Stored tag names.

See also
AstarPath.FindTagNames
AstarPath.GetTagNames

◆ threadCount

ThreadCount threadCount = ThreadCount.One

Number of pathfinding threads to use.

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.

  • None indicates that the pathfinding is run in the Unity thread as a coroutine
  • Automatic will try to adjust the number of threads to the number of cores and memory on the computer. Less than 512mb of memory or a single core computer will make it revert to using no multithreading.

It is recommended that you use one of the "Auto" settings that are available. The reason is that even if your computer might be beefy and have 8 cores. Other computers might only be quad core or dual core in which case they will not benefit from more than 1 or 3 threads respectively (you usually want to leave one core for the unity thread). If you use more threads than the number of cores on the computer it is mostly just wasting memory, it will not run any faster. The extra memory usage is not trivially small. Each thread needs to keep a small amount of data for each node in all the graphs. It is not the full graph data but it is proportional to the number of nodes. The automatic settings will inspect the machine it is running on and use that to determine the number of threads so that no memory is wasted.

The exception is if you only have one (or maybe two characters) active at time. Then you should probably just go with one thread always since it is very unlikely that you will need the extra throughput given by more threads. Keep in mind that more threads primarily increases throughput by calculating different paths on different threads, it will not calculate individual paths any faster.

Note that if you are modifying the pathfinding core scripts or if you are directly modifying graph data without using any of the safe wrappers (like AddWorkItem) multithreading can cause strange errors and pathfinding stopping to work if you are not careful. For basic usage (not modding the pathfinding core) it should be safe.

Note
WebGL does not support threads at all (since javascript is single-threaded) so no threads will be used on that platform.
See also
CalculateThreadCount

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

◆ unwalkableNodeDebugSize

float unwalkableNodeDebugSize = 0.3F

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

Note
Only relevant in the editor. Does not apply to grid graphs.
See also
showUnwalkableNodes

◆ Version

readonly System.Version Version = new System.Version(4, 1, 11)
static

The version number for the A* Pathfinding Project.

◆ waitForPathDepth

int waitForPathDepth = 0
staticprivate

◆ workItemLock

PathProcessor.GraphUpdateLock workItemLock
private

Held if any work items are currently queued.

◆ workItems

readonly WorkItemProcessor workItems
private

Processes work items.

Property Documentation

◆ astarData

AstarData astarData
get

Holds all graph data.

Deprecated:
The 'astarData' field has been renamed to 'data'

◆ graphs

NavGraph [] graphs
get

◆ graphTypes

System.Type [] graphTypes
get

◆ IsAnyGraphUpdateInProgress

bool IsAnyGraphUpdateInProgress
get

Returns if any graph updates are being calculated right now.

Note
This does *not* includes other types of work items such as navmesh cutting or anything added by RegisterSafeUpdate or AddWorkItem.
See also
IsAnyWorkItemInProgress

◆ IsAnyGraphUpdateQueued

bool IsAnyGraphUpdateQueued
get

Returns if any graph updates are waiting to be applied.

Note
This is false while the updates are being performed.
This does *not* includes other types of work items such as navmesh cutting or anything added by RegisterSafeUpdate or AddWorkItem.

◆ IsAnyGraphUpdatesQueued

bool IsAnyGraphUpdatesQueued
get

Returns if any graph updates are waiting to be applied.

Deprecated:
Use IsAnyGraphUpdateQueued instead

◆ IsAnyWorkItemInProgress

bool IsAnyWorkItemInProgress
get

Returns if any work items are in progress right now.

Note
This includes pretty much all types of graph updates. Such as normal graph updates, navmesh cutting and anything added by RegisterSafeUpdate or AddWorkItem.

◆ IsInsideWorkItem

bool IsInsideWorkItem
getpackage

Returns if this code is currently being exectuted inside a work item.

Note
This includes pretty much all types of graph updates. Such as normal graph updates, navmesh cutting and anything added by RegisterSafeUpdate or AddWorkItem.

In contrast to IsAnyWorkItemInProgress this is only true when work item code is being executed, it is not true in-between the updates to a work item that takes several frames to complete.

◆ isScanning

bool isScanning
getprivate set

Set while any graphs are being scanned.

It will be true up until the FloodFill is done.

Note
Not to be confused with graph updates.

Used to better support Graph Update Objects called for example in OnPostScan

See also
IsAnyGraphUpdateQueued
IsAnyGraphUpdateInProgress

◆ IsUsingMultithreading

bool IsUsingMultithreading
get

Returns whether or not multithreading is used.

Exceptions
System.ExceptionIs thrown when it could not be decided if multithreading was used or not. This should not happen if pathfinding is set up correctly.
Note
This uses info about if threads are running right now, it does not use info from the settings on the A* object.

◆ lastScanTime

float lastScanTime
getprivate set

The time it took for the last call to Scan() to complete.

Used to prevent automatically rescanning the graphs too often (editor only)

◆ limitGraphUpdates

bool limitGraphUpdates
getset

Batch graph updates.

Deprecated:
This field has been renamed to batchGraphUpdates.

◆ maxGraphUpdateFreq

float maxGraphUpdateFreq
getset

Limit for how often should graphs be updated.

Deprecated:
This field has been renamed to graphUpdateBatchingInterval.

◆ maxNearestNodeDistanceSqr

float maxNearestNodeDistanceSqr
get

Max Nearest Node Distance Squared.

See also
maxNearestNodeDistance

◆ NumParallelThreads

int NumParallelThreads
get

Number of parallel pathfinders.

Returns the number of concurrent processes which can calculate paths at once. When using multithreading, this will be the number of threads, if not using multithreading it is always 1 (since only 1 coroutine is used).

See also
IsUsingMultithreading

The documentation for this class was generated from the following file: