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.

Inner Types

Public Methods

AddWorkItem (...)

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

AllocateNodes<T> (result, count, createNode, variantsPerNode)

Allocate a bunch of nodes at once.

Calls OnDrawGizmos on all graphs.

Forces graph updates to complete in a single frame.

Forces work items to complete in a single frame.

Obstacle data for navmesh edges.

GetNearest (...)

Returns the n...

Returns tag names.

IsPointOnNavmesh (position)

True if the point is on a walkable part of the navmesh, as seen from above.

Linecast (start, end, [hit])

True if there is an obstacle between start and end on the navmesh.

Allows you to access read-only graph data in jobs safely.

Aquires an exclusive lock on the graph data asynchronously.

Aquires an exclusive lock on the graph data.

Blocks until all pathfinding threads are paused and blocked.

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

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

Scan ([...])

Scans a...

ScanAsync ([...])

Scans a...

Snapshot (bounds, graphMask)

Captures a snapshot of a part of the graphs, to allow restoring it later.

UpdateGraphs (..., [delay])

Update all graphs...

Public Static Methods

Blocks until the path has been calculated.

Calculates number of threads to use.

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

Tries to find an AstarPath object and return tag names.

StartPath (path, pushToFront=…, assumeInPlayMode=…)

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

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

Shortcut to AstarData.graphs.

Public
heuristic

The distance function to use as a heuristic.

Public
heuristicScale

The scale of the heuristic.

Public
isScanning

True 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 on pathfinding during each frame.

Public
maxNearestNodeDistance

Maximum distance to search for nodes.

Public
maxNearestNodeDistanceSqr

Max Nearest Node Distance Squared.

Public
navmeshUpdates

Handles navmesh cuts.

offMeshLinks

Holds all active off-mesh links.

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
OnPathsCalculated

Called right after callbacks on paths have been called.

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

Awake ()

Blocks until the currently running async scan (if any) has completed.

Waits a moment with updating graphs.

DestroyNode (node)

Internal method to destroy a given node.

DirtyBounds (bounds)

Returns the next free path ID.

Initializes temporary path data for a node.

InitializeNodes (nodes)

Initializes the pathProcessor field.

IsInsideWorkItem

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

Internal

Prints path results to the log.

NNConstraintClosestAsSeenFromAbove

Cached NNConstraint to avoid unnecessary allocations.

Internal Static Readonly

Clears up variables and other stuff, destroys graphs.

Cleans up graphs to avoid memory leaks.

Called after this component is enabled.

OnGUI ()

Draws the InGame debugging (if enabled)

OnUpgradeSerializedData (migrations, unityThread)

Handle serialization backwards compatibility.

Reset ()

Handle serialization backwards compatibility.

ScanInternal (graphsToScan, async)
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.

UpdateGraphsInternal (ob, delay)

Update all graphs using the GraphUpdateObject after delay seconds.

UpgradeSerializedData (isUnityThread)
asyncScanTask

If an async scan is running, this will be set to the coroutine.

Private
debugPathData

The path to debug using gizmos.

Internal
debugPathID

The path ID to debug using gizmos.

Internal
graphDataLock

Global read-write lock for graph data.

Private
graphUpdateRoutineRunning
Private
graphUpdates

Processes graph updates.

Private Readonly
graphUpdatesWorkItemAdded

Makes sure QueueGraphUpdates will not queue multiple graph update orders.

Private
hasScannedGraphAtStartup
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
lastGraphUpdate

Time the last graph update was done.

Private
nextFreePathID

The next unused Path ID.

Private
nodeStorage

Holds global node data that cannot be stored in individual graphs.

Internal
pathProcessor

Holds all paths waiting to be calculated and calculates them.

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

prioritizeGraphs

Prioritize graphs.

Public
prioritizeGraphsLimit

Distance limit for prioritizeGraphs.

Public