Class AstarPath Extends VersionedMonoBehaviour

Public

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.

Public Methods

AddWorkItem (callback)

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

Public
AddWorkItem (item)

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

Public
FloodFill ()

Floodfills all graphs and updates areas for every node.

Public
FloodFill (seed)

Floodfills starting from the specified node.

Public
FloodFill (seed, area)

Floodfills starting from 'seed' using the specified area.

Public
FlushGraphUpdates ()

Forces graph updates to complete in a single frame.

Public
FlushWorkItems ()

Forces work items to complete in a single frame.

Public
GetNearest (position)

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

Public
GetNearest (ray)

Returns the node closest to the ray (slow).

Public
GetNearest (position, constraint)

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

Public
GetNearest (position, constraint, hint)

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

Public
GetTagNames ()

Returns tag names.

Public
PausePathfinding ()

Blocks until all pathfinding threads are paused and blocked.

Public
QueueGraphUpdates ()

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

Public
Scan (graphsToScan=null)

Scans all specified graphs.

Public
Scan (graphToScan)

Scans a particular graph.

Public
ScanAsync (graphToScan)

Scans a particular graph asynchronously.

Public
ScanAsync (graphsToScan=null)

Scans all specified graphs asynchronously.

Public
UpdateGraphs (bounds)

Update all graphs within bounds.

Public
UpdateGraphs (ob)

Update all graphs using the GraphUpdateObject.

Public
UpdateGraphs (bounds, delay)

Update all graphs within bounds after delay seconds.

Public
UpdateGraphs (ob, delay)

Update all graphs using the GraphUpdateObject after delay seconds.

Public

Public Static Methods

BlockUntilCalculated (path)

Blocks until the path has been calculated.

Public Static
CalculateThreadCount (count)

Calculates number of threads to use.

Public Static
FindTagNames ()

Tries to find an AstarPath object and return tag names.

Public Static
StartPath (path, pushToFront=…)

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

Public Static

Public Variables

batchGraphUpdates

Throttle graph updates and batch them to improve performance.

Public
colorSettings

Reference to the color settings for this AstarPath object.

Public
data

Holds all graph data.

Public
debugFloor

Low value to use for certain debugMode modes.

Public
debugMode

The mode to use for drawing nodes in the sceneview.

Public
debugPathData

The path to debug using gizmos.

Public
debugPathID

The path ID to debug using gizmos.

Public
debugRoof

High value to use for certain debugMode modes.

Public
euclideanEmbedding

Holds settings for heuristic optimization.

Public
fullGetNearestSearch

Do a full GetNearest search for all graphs.

Public
graphs
Public
graphUpdateBatchingInterval

Minimum number of seconds between each batch of graph updates.

Public
heuristic

The distance function to use as a heuristic.

Public
heuristicScale

The scale of the heuristic.

Public
IsAnyGraphUpdateInProgress

Returns if any graph updates are being calculated right now.

Public
IsAnyGraphUpdateQueued

Returns if any graph updates are waiting to be applied.

Public
IsAnyWorkItemInProgress

Returns if any work items are in progress right now.

Public
isScanning

Set while any graphs are being scanned.

Public
IsUsingMultithreading

Returns whether or not multithreading is used.

Public
lastScanTime

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

Public
logPathResults

The amount of debugging messages.

Public
manualDebugFloorRoof

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

Public
maxFrameTime

Max number of milliseconds to spend each frame for pathfinding.

Public
maxNearestNodeDistance

Maximum distance to search for nodes.

Public
maxNearestNodeDistanceSqr

Max Nearest Node Distance Squared.

Public
NumParallelThreads

Number of parallel pathfinders.

Public
prioritizeGraphs

Prioritize graphs.

Public
prioritizeGraphsLimit

Distance limit for prioritizeGraphs.

Public
scanOnStartup

If true, all graphs will be scanned during Awake.

Public
showGraphs

Shows or hides graph inspectors.

Public
showNavGraphs

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

Public
showSearchTree

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

Public
showUnwalkableNodes

Toggle to show unwalkable nodes.

Public
threadCount

Number of pathfinding threads to use.

Public
unwalkableNodeDebugSize

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

Public

Public Static Variables

active

Returns the active AstarPath object in the scene.

Public Static
Branch

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

Public Static Readonly
Distribution

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

Public Static Readonly
On65KOverflow

Called when pathID overflows 65536 and resets back to zero.

Public Static
OnAwakeSettings

Called on Awake before anything else is done.

Public Static
OnGraphPostScan

Called for each graph after they have been scanned.

Public Static
OnGraphPreScan

Called for each graph before they are scanned.

Public Static
OnGraphsUpdated

Called when any graphs are updated.

Public Static
OnLatePostScan

Called after scanning has completed fully.

Public Static
OnPathPostSearch

Called for each path after searching.

Public Static
OnPathPreSearch

Called for each path before searching.

Public Static
OnPostScan

Called after scanning.

Public Static
OnPreScan

Called before starting the scanning.

Public Static
Version

The version number for the A* Pathfinding Project.

Public Static Readonly

Public Enums

AstarDistribution

Information about where the package was downloaded.

Public

Private/Protected Members

AstarPath ()
Private
Awake ()

Sets up all needed variables and scans the graphs.

Protected
DelayedGraphUpdate ()

Waits a moment with updating graphs.

Private
DestroyNode (node)

Internal method to destroy a given node.

Package
GetNewNodeIndex ()

Returns a new global node index.

Package
GetNextPathID ()

Returns the next free path ID.

Package
gizmos
Private
graphUpdateRoutineRunning
Private
graphUpdates

Processes graph updates.

Private Readonly
graphUpdatesWorkItemAdded

Makes sure QueueGraphUpdates will not queue multiple graph update orders.

Private
inGameDebugPath

Debug string from the last completed path.

Private
InitializeAstarData ()

Initializes the AstarData class.

Private
InitializeNode (node)

Initializes temporary path data for a node.

Package
InitializePathProcessor ()

Initializes the pathProcessor field.

Private
InitializeProfiler ()

Calls AstarProfiler.InitializeFastProfile.

Private
IsInsideWorkItem

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

Package
isScanningBacking

Backing field for isScanning.

Private
lastGraphUpdate

Time the last graph update was done.

Private
LogPathResults (path)

Prints path results to the log.

Private
nextFreePathID

The next unused Path ID.

Private
OnApplicationQuit ()

Terminates pathfinding threads when the application quits.

Private
OnDestroy ()

Clears up variables and other stuff, destroys graphs.

Private
OnDisable ()

Cleans up meshes to avoid memory leaks.

Private
OnDrawGizmos ()

Calls OnDrawGizmos on graph generators.

Private
OnGUI ()

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

Private
OnUpgradeSerializedData (version, unityThread)

Handle serialization backwards compatibility.

Protected
pathProcessor

Holds all paths waiting to be calculated and calculates them.

Private
pathReturnQueue

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

Package Readonly
PausePathfindingSoon ()

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

Private
PerformBlockingActions (force=…)
Private
RecalculateDebugLimits ()
Private
ScanGraph (graph)
Private
tagNames

Stored tag names.

Protected
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.

Private
UpdateGraphsInternal (ob, delay)

Update all graphs using the GraphUpdateObject after delay seconds.

Private
VerifyIntegrity ()

Does simple error checking.

Package
waitForPathDepth
Private Static
workItemLock

Held if any work items are currently queued.

Private
workItems

Processes work items.

Private Readonly

Deprecated Members

astarData

Holds all graph data.

Public
BlockUntilPathQueueBlocked ()

Blocks until all pathfinding threads are paused and blocked.

Public
EnsureValidFloodFill ()

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

Public
FlushThreadSafeCallbacks ()

Forces thread safe callbacks to run.

Public
FlushWorkItems (unblockOnComplete, block)

Make sure work items are executed.

Public
graphTypes
Public
IsAnyGraphUpdatesQueued

Returns if any graph updates are waiting to be applied.

Public
limitGraphUpdates

Batch graph updates.

Public
maxGraphUpdateFreq

Limit for how often should graphs be updated.

Public
minAreaSize

Defines the minimum amount of nodes in an area.

Public
OnGraphsWillBeUpdated
Public
OnGraphsWillBeUpdated2
Public
QueueWorkItemFloodFill ()

Call during work items to queue a flood fill.

Public
RegisterSafeUpdate (callback)

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

Public Static
RegisterSafeUpdate (callback, threadSafe)

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

Public Static
ScanLoop (statusCallback)

Scans all graphs.

Public
WaitForPath (path)

Wait for the specified path to be calculated.

Public Static