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 bit more memory than a regular grid graph, but is otherwise equivalent.

Note

The graph supports 16 layers by default, but it can be increased to 256 by enabling the ASTAR_LEVELGRIDNODE_MORE_LAYERS option in the A* Inspector -> Settings -> Optimizations tab.

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

Public Methods

CountNodes ()

Number of nodes in the graph.

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

Get all nodes in a rectangle.

Public
LayerGridGraph ()
Public

Public Variables

LayerCount
Public
MaxLayers
Public
characterHeight

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

Public

Inherited Public Members

AlignToTilemap (grid)

Aligns this grid to a given tilemap or grid layout.

Public
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
ConvertHexagonSizeToNodeSize (mode, value)

Converts a hexagon dimension to a node size.

Public Static
ConvertNodeSizeToHexagonSize (mode, value)

Converts an internal node size to a hexagon dimension.

Public Static
Depth
Public
FixedPrecisionScale

Scaling used for the coordinates in the Linecast methods that take normalized points using integer coordinates.

Public Static
GetBoundsFromRect (rect)

Bounding box in world space which encapsulates all nodes in the given rectangle.

Public
GetConnectionCost (dir)

Default cost of moving one node in a particular direction.

Public
GetNearest (position, constraint, maxDistanceSqr)

Nearest node to a position using the specified NNConstraint.

Public
GetNearest (position, constraint=null)

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

Public
GetNeighbourDirections (neighbours)

Neighbour direction indices to use depending on how many neighbours each node should have.

Public Static
GetNode (x, z)

Node in the specified cell.

Public
GetNodes (action)

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

Public
GetNodesInRegion (bounds)

All nodes inside the bounding box.

Public
GetNodesInRegion (shape)

All nodes inside the shape.

Public
GetNodesInRegion (rect)

Get all nodes in a rectangle.

Public
GetRectFromBounds (bounds)

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

Public
GraphPointToWorld (x, z, height)

Transform a point in graph space to world space.

Public
IsInsideBounds (point)

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

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, hit, trace=null, filter=null)

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, hit, trace=null, filter=null)

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

Public
Linecast (fromNode, normalizedFromPoint, toNode, normalizedToPoint, hit, trace=null, filter=null, continuePastEnd=…)

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

Public
Linecast (fromNode, fixedNormalizedFromPoint, toNode, fixedNormalizedToPoint, hit, trace=null, filter=null, continuePastEnd=…)

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

Public
MaxLayers
Public
NearestNodeDistanceSqrLowerBound (position, constraint)

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

Public
OnDrawGizmos (gizmos, drawNodes, redrawScope)

Draw gizmos for the graph.

Public
RecalculateAllConnections ()

Recalculates node connections for all nodes in grid graph.

Public
RecalculateConnectionsInRegion (recalculateRect)

Recalculates node connections for all nodes in a given region of the grid.

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
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
SetWalkability (walkability, rect)

Set walkability for multiple nodes at once.

Public
Snapshot (bounds)

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

Public
StandardDimetricAngle

Commonly used value for isometricAngle.

Public Static Readonly
StandardIsometricAngle

Commonly used value for isometricAngle.

Public Static Readonly
TranslateInDirection (dx, dz)

Moves the grid by a number of nodes.

Public
UpdateTransform ()

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

Public
Width
Public
active

Reference to the AstarPath object in the scene.

Public
aspectRatio

Scaling of the graph along the X axis.

Public
bounds

World bounding box for the graph.

Public
bounds

World bounding box for the graph.

Public
center

Center point of the grid in world space.

Public
collision

Settings on how to check for walkability and height.

Public
cutCorners

If disabled, will not cut corners on obstacles.

Public
depth

Depth (height) of the grid in nodes.

Public
drawGizmos

Enable to draw gizmos in the Unity scene view.

Public
erodeIterations

Number of times to erode the graph.

Public
erosionFirstTag

Tag to start from when using tags for erosion.

Public
erosionTagsPrecedenceMask

Bitmask for which tags can be overwritten by erosion tags.

Public
erosionUseTags

Use tags instead of walkability for erosion.

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

Get or set if the graph should be in 2D mode.

Public
isScanned
Public
isometricAngle

Angle in degrees to use for the isometric projection.

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

Public
name

Name of the graph.

Public
neighbourCosts

Costs to neighbour nodes.

Public Readonly
neighbourOffsets

Index offset to get neighbour nodes.

Public Readonly
neighbourXOffsets

Offsets in the X direction for neighbour nodes.

Public Static Readonly
neighbourZOffsets

Offsets in the Z direction for neighbour nodes.

Public Static Readonly
neighbours

Number of neighbours for each node.

Public
nodeSize

Size of one node in world units.

Public
nodes

All nodes in this graph.

Public
open

Is the graph open in the editor.

Public
persistent

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

Public
rotation

Rotation of the grid in degrees.

Public
rules

Additional rules to use when scanning the grid graph.

Public
showInInspector

True if the graph should be visible in the editor.

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

Width of the grid in nodes.

Public

Private/Protected Members

AllocateNodesJob (size, dependency)
Protected
AllocateNodesJob (size, dependency)
Protected
AssertSafeToUpdateGraph ()

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

Protected
ClipLineSegmentToBounds (a, b, outA, outB)

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

Protected
CrossMagnitude (a, b)

Magnitude of the cross product a x b.

Protected Static
DeserializeExtraInfo (ctx)

Deserializes graph type specific node data.

Protected
DeserializeNativeData (ctx, normalsSerialized)
Protected
DeserializeNodeSurfaceNormals (ctx, nodes, ignoreForCompatibility)
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
DrawUnwalkableNodes (gizmos, size, redrawScope)
Protected
GetNearestFromGraphSpace (positionGraphSpace)
Protected
GetNearestNode (position, x, z, constraint)
Private
GetNodesInRegion (bounds, shape)

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

Protected
HexagonConnectionMask

Mask based on hexagonNeighbourIndices.

Internal 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
SerializeExtraInfo (ctx)

Serializes graph type specific node data.

Protected
SerializeNodeSurfaceNormals (ctx)
Protected
allNeighbourIndices

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

Internal Static Readonly
axisAlignedNeighbourIndices

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

Internal Static Readonly
exists

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

Internal
hexagonNeighbourIndices

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

Internal Static Readonly
lastScannedDepth
Internal
lastScannedWidth
Internal
layerCount

Number of layers.

Internal
newGridNodeDelegate

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

Protected
nodeData

Internal data for each node.

Protected
nodeDataRef
Internal
useRaycastNormal

Use heigh raycasting normal for max slope calculation.

Protected