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 the nodes do not have a surface.

Inspector

Root

Childs of this transform are treated as nodes.

Recursive

Recursively search for child nodes to the root.

Tag

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

Max Distance

Max distance for a connection to be valid.

Max Distance (axis aligned)

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

Raycast

Use raycasts to check connections.

Raycast → Use 2D Physics

Use the 2D Physics API.

Raycast → Thick Raycast

Use thick raycast.

Raycast → Thick Raycast -> Radius

Thick raycast radius.

Raycast → Mask

Layer mask to use for raycast.

Optimize For Sparse Graph

Optimizes the graph for sparse graphs.

Nearest Node Queries Find Closest

Distance query mode.

Initial Penalty

Default penalty to apply to all nodes.

Inner Types

Public Methods

AddNode ([node], position)

Add a node...

Recalculates connections for all nodes in the graph.

Number of nodes in the graph.

IsValidConnection (a, b, dist)

Returns if the connection between a and b is valid.

OnDrawGizmos (gizmos, drawNodes, redrawScope)

Draw gizmos for the graph.

RandomPointOnSurface (nnConstraint=null, highQuality=true)

A random point on the graph.

Rebuilds a cache used when nearestNodeDistanceMode = NodeDistanceMode.ToConnection.

Rebuilds the lookup structure for nodes.

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

RelocateNodes (deltaMatrix)

Moves the nodes in this graph.

RemoveNode (node)

Removes a node from the graph.

Public Variables

isScanned

True if the graph has been scanned and contains nodes.

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, [...])

...

GetNodes (action)

Calls a delegate with all nodes in the graph...

IsInsideBounds (point)

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

IsPointOnNavmesh (position)

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

NearestNodeDistanceSqrLowerBound (position, constraint=null)

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

Scan ()

Scan the graph.

Snapshot (bounds)

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

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.

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

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

Calculates connections for all nodes in the graph.

Recursively counds children of a transform.

CreateNodes (count)

Deserializes graph type specific node data.

Destroys all nodes in the graph.

DirtyBounds (bounds)

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

Cleans up any unmanaged data that the graph has.

DrawChildren (draw, graph, tr)
DrawUnwalkableNodes (gizmos, size, redrawScope)
FindClosestConnectionPoint (node, position, maxDistanceSqr)
LongestConnectionLength (nodes, nodeCount)
NodeColor
Private Static Readonly

Function for cleaning up references.

Called after all deserialization has been done for all graphs.

ScanInternal ([...])

Internal method to scan the graph.

ScheduleGraphUpdates (graphUpdates)

Updates an area in the list graph.

Serializes graph type specific node data.

exists

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

Internal
lookupTree
Private
maximumConnectionLength

Longest known connection.

Private