Class LayerGridGraph Extends GridGraph, IUpdatableGraph

Public

Grid Graph, supports layered worlds.

The GridGraph is great in many ways, reliable, easily configured and updatable during runtime. But it lacks support for worlds which have multiple layers, such as a building with multiple floors.
That's where this graph type comes in. It supports basically the same stuff as the grid graph, but also multiple layers. It uses a more memory, and is probably a bit slower.

Note

Does not support 8 connections per node, only 4.

A* Pro Feature:

This is an A* Pathfinding Project Pro feature only. This function/class/variable might not exist in the Free version of the A* Pathfinding Project or the functionality might be limited.
The Pro version can be bought here

Inner Types

Struct returned by SampleHeights.

Sorts RaycastHits by distance.

Public Methods

CalculateConnections (node)

Calculates the grid connections for a single node.

Public
CalculateConnections (x, z)

Calculates connections for all nodes in a cell (there may be multiple layers of nodes)

Public
CalculateConnections (x, z, layerIndex)

Calculates the layered grid graph connections for a single node.

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
GetNode (x, z)

Node in the specified cell in the first layer.

Public
GetNode (x, z, layer)

Node in the specified cell.

Public
GetNodes (action)

Calls a delegate with all nodes in the graph.

Public
GetNodesInRegion (rect)

Get all nodes in a rectangle.

Public
GetNodesInRegion (rect, buffer)

Get all nodes in a rectangle.

Public
LayerGridGraph ()
Public
RecalculateCell (x, z, resetPenalties=true, resetTags=true)

Recalculates single cell.

Public

Public Variables

characterHeight

Nodes with a short distance to the node above it will be set unwalkable.

Public
LayerCount
Public
MaxLayers
Public
uniformWidthDepthGrid
Public

Inherited Public Members

active

Reference to the AstarPath object in the scene.

Public
aspectRatio

Scaling of the graph along the X axis.

Public
BATCH_SIZE
Public Static
CalculateConnectionsForCellAndNeighbours (x, z)

Calculates the grid connections for a cell as well as its neighbours.

Public
CalculateTransform ()

Returns a new transform which transforms graph space to world space.

Public
center

Center point of the grid.

Public
CheckConnection (node, dir)

Returns if node is connected to it's neighbour in the specified direction.

Public
collision

Settings on how to check for walkability and height.

Public
ConvertHexagonSizeToNodeSize (mode, value)
Public Static
ConvertNodeSizeToHexagonSize (mode, value)
Public Static
cutCorners

If disabled, will not cut corners on obstacles.

Public
Depth
Public
depth

Depth (height) of the grid in nodes.

Public
drawGizmos

Enable to draw gizmos in the Unity scene view.

Public
erodeIterations

Erosion of the graph.

Public
ErodeWalkableArea ()

Erodes the walkable area.

Public
ErodeWalkableArea (xmin, zmin, xmax, zmax)

Erodes the walkable area.

Public
erosionFirstTag

Tag to start from when using tags for erosion.

Public
erosionUseTags

Use tags instead of walkability for erosion.

Public
GetConnectionCost (dir)
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
getNearestForceOverlap

In GetNearestForce, determines how far to search after a valid node has been found.

Public
GetNodes (action)

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

Public
GetNodesInRegion (shape)

All nodes inside the shape.

Public
GetNodesInRegion (bounds)

All nodes inside the bounding box.

Public
GetRectFromBounds (bounds)

A rect that contains all nodes that the bounds could touch.

Public
graphIndex

Index of the graph, used for identification purposes.

Public
GraphPointToWorld (x, z, height)

Transform a point in graph space to world space.

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
inspectorGridMode

Determines the layout of the grid graph inspector in the Unity Editor.

Public
inspectorHexagonSizeMode

Determines how the size of each hexagon is set in the inspector.

Public
isometricAngle

Angle to use for the isometric projection.

Public
IsValidConnection (node1, node2)

Returns true if a connection between the adjacent nodes n1 and n2 is valid.

Public
LayerCount

Number of layers in the graph.

Public
Linecast (from, to)

Returns if there is an obstacle between from and to on the graph.

Public
Linecast (from, to, hint)

Returns if there is an obstacle between from and to on the graph.

Public
Linecast (fromNode, toNode, filter=null)

Returns if there is an obstacle between the two nodes on the graph.

Public
Linecast (from, to, hint, hit)

Returns if there is an obstacle between from and to on the graph.

Public
Linecast (from, to, hint, hit, trace)

Returns if there is an obstacle between from and to on the graph.

Public
Linecast (from, to, hit, trace, filter)

Returns if there is an obstacle between from and to on the graph.

Public
MaxLayers
Public
maxSlope

The max slope in degrees for a node to be walkable.

Public
maxStepHeight

The max y coordinate difference between two nodes to enable a connection.

Public
maxStepUsesSlope

Take the slope into account for maxClimb.

Public
name

Name of the graph.

Public
neighbourCosts

Costs to neighbour nodes.

Public Readonly
neighbourOffsets

Index offset to get neighbour nodes.

Public Readonly
neighbours

Number of neighbours for each node.

Public
neighbourXOffsets

Offsets in the X direction for neighbour nodes.

Public Static Readonly
neighbourZOffsets

Offsets in the Z direction for neighbour nodes.

Public Static Readonly
nodes

All nodes in this graph.

Public
nodeSize

Size of one node in world units.

Public
OnDrawGizmos (gizmos, drawNodes, redrawScope)

Draw gizmos for the graph.

Public
open

Is the graph open in the editor.

Public
RecalculationMode
Public
RelocateNodes (deltaMatrix)

Moves the nodes in this graph.

Public
RelocateNodes (center, rotation, nodeSize, aspectRatio=1, isometricAngle=0)

Relocate the grid graph using new settings.

Public
rotation

Rotation of the grid in degrees.

Public
rules

Additional rules to use when scanning the grid graph.

Public
Scan ()

Scan the graph.

Public
SetDimensions (width, depth, nodeSize)

Updates unclampedSize from width, depth and nodeSize values.

Public
SetGridShape (shape)

Changes the grid shape.

Public
SetUpOffsetsAndCosts ()

Sets up neighbourOffsets with the current settings.

Public
showMeshOutline

Show an outline of the grid nodes in the Unity Editor.

Public
showMeshSurface

Show the surface of the graph.

Public
showNodeConnections

Show the connections between the grid nodes in the Unity Editor.

Public
size

Size of the grid.

Public
SnappedLinecast (from, to, hint, hit)

Returns if there is an obstacle between from and to on the graph.

Public
StandardDimetricAngle

Commonly used value for isometricAngle.

Public Static Readonly
StandardIsometricAngle

Commonly used value for isometricAngle.

Public Static Readonly
transform

Determines how the graph transforms graph space to world space.

Public
unclampedSize

Size of the grid.

Public
uniformEdgeCosts

If true, all edge costs will be set to the same value.

Public
uniformWidthDepthGrid

This is placed here so generators inheriting from this one can override it and set it to false.

Public
UpdateTransform ()

Updates the transform field which transforms graph space to world space.

Public
USE_BURST
Public Static
USE_BURST_UPDATE
Public Static
useJumpPointSearch

Use jump point search to speed up pathfinding.

Public
width

Width of the grid in nodes.

Public
Width
Public

Private/Protected Members

AddLayers (count)

Increases the capacity of the nodes array to hold more layers.

Private
AllocateNodesJob (size, dependency)
Protected
AllocateNodesJob (size, dependency)
Protected
CalculateAffectedRegions (o, originalRect, affectRect, physicsRect, willChangeWalkability, erosion)
Protected
ClipLineSegmentToBounds (a, b, outA, outB)

Clips a line segment in graph space to the graph bounds.

Protected
comparer

Sorts RaycastHits by distance.

Private Static Readonly
CrossMagnitude (a, b)

Magnitude of the cross product a x b.

Protected Static
CrossMagnitude (a, b)

Magnitude of the cross product a x b.

Protected Static
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
ErosionAnyFalseConnections (baseNode)

True if the node has any blocked connections.

Protected
exists

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

Package
GetNearestNode (position, x, z, constraint)
Private
GetNodesInRegion (bounds, shape)

All nodes inside the shape or if null, the bounding box.

Protected
heightSampleBuffer

Internal buffer used by SampleHeights.

Private Static
hexagonNeighbourIndices

Which neighbours are going to be used when neighbours=6.

Package Static Readonly
lastScannedDepth
Package
lastScannedWidth
Package
layerCount

Number of layers.

Package
newGridNodeDelegate

Delegate which creates and returns a single instance of the node type for this graph.

Protected
OnDestroy ()

Function for cleaning up references.

Protected
PostDeserialization (ctx)

Called after all deserialization has been done for all graphs.

Protected
RemoveGridGraphFromStatic ()
Private
SampleHeights (collision, mergeSpanRange, position, numHits)

Fires a ray from the sky and returns a sample for everything it hits.

Protected Static
ScanInternal (async)

Internal method to scan the graph.

Protected
SerializeExtraInfo (ctx)

Serializes graph type specific node data.

Protected
UpdateRegion (bounds, dependencyTracker, allocator, dependsOn=…)
Package
useRaycastNormal

Use heigh raycasting normal for max slope calculation.

Protected

Deprecated Members

CalculateConnections (x, z, layerIndex, node)

Calculates the layered grid graph connections for a single node.

Public
CheckConnection (node, dir)

Returns if node is connected to it's neighbour in the specified direction.

Public Static
ScanInternal ()

Internal method to scan the graph.

Protected