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 (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
AllocateNodes< T > (result, count, createNode)

Allocate a bunch of nodes at once.

Public
DrawGizmos ()

Calls OnDrawGizmos on graph generators.

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.

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
GetNearest (ray)

Returns the node closest to the ray (slow).

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 (graphToScan)

Scans a particular graph.

Public
Scan (graphsToScan=null)

Scans all specified graphs.

Public
ScanAsync (graphToScan)

Scans a particular graph asynchronously.

Public
ScanAsync (graphsToScan=null)

Scans all specified graphs asynchronously.

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
UpdateGraphs (bounds)

Update all graphs within bounds.

Public
UpdateGraphs (ob)

Update all graphs using the GraphUpdateObject.

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
FindAstarPath ()

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

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

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
IsUsingMultithreading

Returns whether or not multithreading is used.

Public
NumParallelThreads

Number of parallel pathfinders.

Public
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
graphUpdateBatchingInterval

Minimum number of seconds between each batch of graph updates.

Public
graphs
Public
heuristic

The distance function to use as a heuristic.

Public
heuristicScale

The scale of the heuristic.

Public
isScanning

Set while any graphs are being scanned.

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
navmeshUpdates

Handles navmesh cuts.

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

Visualize 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

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
active

Returns the active AstarPath object in the scene.

Public Static

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.

Internal
GetNextPathID ()

Returns the next free path ID.

Internal
InitializeAstarData ()

Initializes the AstarData class.

Private
InitializeNode (node)

Initializes temporary path data for a node.

Internal
InitializePathProcessor ()

Initializes the pathProcessor field.

Private
InitializeProfiler ()

Calls AstarProfiler.InitializeFastProfile.

Private
IsInsideWorkItem

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

Internal
LogPathResults (path)

Prints path results to the log.

Private
NNConstraintNone

Cached NNConstraint.None to avoid unnecessary allocations.

Private Static Readonly
OnDestroy ()

Clears up variables and other stuff, destroys graphs.

Private
OnDisable ()

Cleans up graphs to avoid memory leaks.

Private
OnEnable ()
Private
OnGUI ()

Draws the InGame debugging (if enabled)

Private
OnUpgradeSerializedData (version, unityThread)

Handle serialization backwards compatibility.

Protected
PausePathfindingSoon ()

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

Private
PerformBlockingActions (force=…)
Private
RecalculateDebugLimits ()
Private
Reset ()

Handle serialization backwards compatibility.

Protected
ScanGraph (graph, async)
Private
ScanInternal (graphsToScan, async)
Private
ShutdownPathfindingThreads ()
Private
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.

Internal
graphUpdateRoutineRunning
Private
graphUpdates

Processes graph updates.

Private Readonly
graphUpdatesWorkItemAdded

Makes sure QueueGraphUpdates will not queue multiple graph update orders.

Private
hierarchicalGraph

Holds a hierarchical graph to speed up some queries like if there is a path between two nodes.

Internal Readonly
inGameDebugPath

Debug string from the last completed path.

Private
isScanningBacking

Backing field for isScanning.

Private
lastGraphUpdate

Time the last graph update was done.

Private
nextFreePathID

The next unused Path ID.

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

Internal Readonly
redrawScope
Private
tagNames

Stored tag names.

Protected
waitForPathDepth
Private Static
workItemLock

Held if any work items are currently queued.

Private
workItems

Processes work items.

Private Readonly

Deprecated Members

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
FloodFill (seed)

Floodfills starting from the specified node.

Public
FloodFill (seed, area)

Floodfills starting from 'seed' using the specified area.

Public
FloodFill ()

Floodfills all graphs and updates areas for every node.

Public
FlushThreadSafeCallbacks ()

Forces thread safe callbacks to run.

Public
FlushWorkItems (unblockOnComplete, block)

Make sure work items are executed.

Public
IsAnyGraphUpdatesQueued

Returns if any graph updates are waiting to be applied.

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
WaitForPath (path)

Wait for the specified path to be calculated.

Public Static
astarData

Holds all graph data.

Public
graphTypes
Public
limitGraphUpdates

Batch graph updates.

Public
maxGraphUpdateFreq

Limit for how often should graphs be updated.

Public