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. You can enable optimizeForSparseGraph which will in most cases reduce the calculation times drastically.

Note

Does not support linecast because of obvious reasons.

Inner Types

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, maxDistanceSqr)

Nearest node to a position using the specified NNConstraint.

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
OnDrawGizmos (gizmos, drawNodes, redrawScope)

Draw gizmos for the graph.

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

isScanned
Public
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, constraint=null)

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
IsInsideBounds (point)

True if the point is inside the bounding box of this graph.

Public
NearestNodeDistanceSqrLowerBound (position, constraint=null)

Lower bound on the squared distance from the given point to the closest node in this graph.

Public
Scan ()

Scan the graph.

Public
Snapshot (bounds)

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

Public
active

Reference to the AstarPath object in the scene.

Public
bounds

World bounding box for the graph.

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
persistent

True if the graph will be included when serializing graph data.

Public
showInInspector

True if the graph should be visible in the editor.

Public

Private/Protected Members

AddChildren (nodes, c, tr)

Recursively adds childrens of a transform as nodes.

Protected Static
AddToLookup (node)
Private
AssertSafeToUpdateGraph ()

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

Protected
BuildNodeLookup (nodes, nodeCount, optimizeForSparseGraph)
Private Static
ConnectNodesAsync (nodes, nodeCount, lookupTree, maxDistance, limits, graph)

Calculates connections for all nodes in the graph.

Private Static
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
DirtyBounds (bounds)

Notifies the system that changes have been made inside these bounds.

Protected
DisposeUnmanagedData ()

Cleans up any unmanaged data that the graph has.

Protected
DrawChildren (draw, graph, tr)
Private Static
DrawUnwalkableNodes (gizmos, size, redrawScope)
Protected
FindClosestConnectionPoint (node, position, maxDistanceSqr)
Private
LongestConnectionLength (nodes, nodeCount)
Private Static
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
ScheduleGraphUpdates (graphUpdates)

Updates an area in the list graph.

Private
SerializeExtraInfo (ctx)

Serializes graph type specific node data.

Protected
exists

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

Internal
lookupTree
Private
maximumConnectionLength

Longest known connection.

Private

Deprecated Members

ScanInternal ()

Internal method to scan the graph.

Protected