Class PointGraph Extends NavGraph, IUpdatableGraph

Public

Basic point graph.

The point graph is the most basic graph structure, it consists of a number of interconnected points in space called nodes or waypoints.
The point graph takes a Transform object as "root", this Transform will be searched for child objects, every child object will be treated as a node. If recursive is enabled, it will also search the child objects of the children recursively. It will then check if any connections between the nodes can be made, first it will check if the distance between the nodes isn't too large (maxDistance) and then it will check if the axis aligned distance isn't too high. The axis aligned distance, named limits, is useful because usually an AI cannot climb very high, but linking nodes far away from each other, but on the same Y level should still be possible. limits and maxDistance are treated as being set to infinity if they are set to 0 (zero).
Lastly it will check if there are any obstructions between the nodes using raycasting which can optionally be thick.
One thing to think about when using raycasting is to either place the nodes a small distance above the ground in your scene or to make sure that the ground is not in the raycast mask to avoid the raycast from hitting the ground.
Alternatively, a tag can be used to search for nodes.

For larger graphs, it can take quite some time to scan the graph with the default settings. If you have the pro version you can enable optimizeForSparseGraph which will in most cases reduce the calculation times drastically.

Note

Does not support linecast because of obvious reasons.

Public Methods

AddNode (position)

Add a node to the graph at the specified position.

Public
AddNode<T> (node, position)

Add a node with the specified type to the graph at the specified position.

Public
ConnectNodes ()

Recalculates connections for all nodes in the graph.

Public
CountNodes ()

Number of nodes in the graph.

Public
GetNearest (position, constraint, hint)

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

Public
GetNearestForce (position, constraint)

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

Public
GetNodes (action)

Calls a delegate with all nodes in the graph.

Public
IsValidConnection (a, b, dist)

Returns if the connection between a and b is valid.

Public
RebuildConnectionDistanceLookup ()

Rebuilds a cache used when nearestNodeDistanceMode = #NodeDistanceMode.ToConnection.

Public
RebuildNodeLookup ()

Rebuilds the lookup structure for nodes.

Public
RegisterConnectionLength (sqrLength)

Ensures the graph knows that there is a connection with this length.

Public
RelocateNodes (deltaMatrix)

Moves the nodes in this graph.

Public

Public Variables

limits

Max distance along the axis for a connection to be valid.

Public
mask

Layer mask to use for raycast.

Public
maxDistance

Max distance for a connection to be valid.

Public
nearestNodeDistanceMode

Distance query mode.

Public
nodeCount

Number of nodes in this graph.

Public
nodes

All nodes in this graph.

Public
optimizeForSparseGraph

Optimizes the graph for sparse graphs.

Public
raycast

Use raycasts to check connections.

Public
recursive

Recursively search for child nodes to the root.

Public
root

Childs of this transform are treated as nodes.

Public
searchTag

If no root is set, all nodes with the tag is used as nodes.

Public
thickRaycast

Use thick raycast.

Public
thickRaycastRadius

Thick raycast radius.

Public
use2DPhysics

Use the 2D Physics API.

Public

Public Enums

NodeDistanceMode

Distance query mode.

Public

Inherited Public Members

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
GetNodes (action)

Calls a delegate with all nodes in the graph until the delegate returns false.

Public
OnDrawGizmos (gizmos, drawNodes, redrawScope)

Draw gizmos for the graph.

Public
Scan ()

Scan the graph.

Public
active

Reference to the AstarPath object in the scene.

Public
drawGizmos

Enable to draw gizmos in the Unity scene view.

Public
graphIndex

Index of the graph, used for identification purposes.

Public
guid

Used as an ID of the graph, considered to be unique.

Public
infoScreenOpen

Used in the editor to check if the info screen is open.

Public
initialPenalty

Default penalty to apply to all nodes.

Public
name

Name of the graph.

Public
open

Is the graph open in the editor.

Public

Private/Protected Members

AddChildren (c, tr)

Recursively adds childrens of a transform as nodes.

Protected
AddToLookup (node)
Private
AssertSafeToUpdateGraph ()

Throws an exception if it is not safe to update internal graph data right now.

Protected
CanUpdateAsync (o)
Private
ConnectNodesAsync ()

Calculates connections for all nodes in the graph.

Private
CountChildren (tr)

Recursively counds children of a transform.

Protected Static
CreateNodes (count)
Protected
DeserializeExtraInfo (ctx)

Deserializes graph type specific node data.

Protected
DestroyAllNodes ()

Destroys all nodes in the graph.

Protected
DisposeUnmanagedData ()

Cleans up any unmanaged data that the graph has.

Protected
DrawUnwalkableNodes (gizmos, size, redrawScope)
Protected
FindClosestConnectionPoint (node, position)
Private
GetNearestInternal (position, constraint, fastCheck)
Private
OnDestroy ()

Function for cleaning up references.

Protected
PostDeserialization (ctx)

Called after all deserialization has been done for all graphs.

Protected
ScanInternal (async)

Internal method to scan the graph.

Protected
SerializeExtraInfo (ctx)

Serializes graph type specific node data.

Protected
UpdateArea (guo)

Updates an area in the list graph.

Private
UpdateAreaInit (o)

May be called on the Unity thread before starting the update.

Private
UpdateAreaPost (o)

May be called on the Unity thread after executing the update.

Private
exists

True if the graph exists, false if it has been destroyed.

Internal
lookupTree
Private
maximumConnectionLength

Longest known connection.

Private

Deprecated Members

DeserializeSettingsCompatibility (ctx)

An old format for serializing settings.

Protected
ScanInternal ()

Internal method to scan the graph.

Protected