A* Pathfinding Project  4.1.6
The A* Pathfinding Project for Unity 3D
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties Events Macros Groups Pages
NavmeshBase Class Referenceabstract

Base class for RecastGraph and NavMeshGraph. More...

Detailed Description

Base class for RecastGraph and NavMeshGraph.

Public Member Functions

abstract GraphTransform CalculateTransform ()
 Returns a new transform which transforms graph space to world space.
 
void EndBatchTileUpdate ()
 End batch updating of tiles.
 
override NNInfoInternal GetNearest (Vector3 position, NNConstraint constraint, GraphNode hint)
 Returns the nearest node to a position using the specified NNConstraint.
 
override NNInfoInternal GetNearestForce (Vector3 position, NNConstraint constraint)
 Returns the nearest node to a position using the specified constraint .
 
override void GetNodes (System.Action< GraphNode > action)
 Calls a delegate with all nodes in the graph.
 
NavmeshTile GetTile (int x, int z)
 Tile at the specified x, z coordinate pair.
 
Bounds GetTileBounds (IntRect rect)
 Returns an XZ bounds object with the bounds of a group of tiles.
 
Bounds GetTileBounds (int x, int z, int width=1, int depth=1)
 Returns an XZ bounds object with the bounds of a group of tiles.
 
Bounds GetTileBoundsInGraphSpace (IntRect rect)
 
Bounds GetTileBoundsInGraphSpace (int x, int z, int width=1, int depth=1)
 Returns an XZ bounds object with the bounds of a group of tiles in graph space.
 
void GetTileCoordinates (int tileIndex, out int x, out int z)
 Tile coordinates from a tile index.
 
Int2 GetTileCoordinates (Vector3 position)
 Returns the tile coordinate which contains the specified position.
 
NavmeshTile[] GetTiles ()
 All tiles.
 
IntRect GetTouchingTiles (Bounds bounds)
 Returns a rect containing the indices of all tiles touching the specified bounds.
 
IntRect GetTouchingTilesInGraphSpace (Rect rect)
 Returns a rect containing the indices of all tiles touching the specified bounds.
 
IntRect GetTouchingTilesRound (Bounds bounds)
 Returns a rect containing the indices of all tiles by rounding the specified bounds to tile borders.
 
Int3 GetVertex (int index)
 Vertex coordinate for the specified vertex index.
 
int GetVertexArrayIndex (int index)
 
Int3 GetVertexInGraphSpace (int index)
 Vertex coordinate in graph space for the specified vertex index.
 
bool Linecast (Vector3 origin, Vector3 end)
 Returns if there is an obstacle between origin and end on the graph.
 
bool Linecast (Vector3 origin, Vector3 end, GraphNode hint, out GraphHitInfo hit)
 Returns if there is an obstacle between origin and end on the graph.
 
bool Linecast (Vector3 origin, Vector3 end, GraphNode hint)
 Returns if there is an obstacle between origin and end on the graph.
 
bool Linecast (Vector3 origin, Vector3 end, GraphNode hint, out GraphHitInfo hit, List< GraphNode > trace)
 Returns if there is an obstacle between origin and end on the graph.
 
override void OnDrawGizmos (Pathfinding.Util.RetainedGizmos gizmos, bool drawNodes)
 
GraphNode PointOnNavmesh (Vector3 position, NNConstraint constraint)
 Finds the first node which contains position.
 
override void RelocateNodes (Matrix4x4 deltaMatrix)
 Moves the nodes in this graph.
 
void RelocateNodes (GraphTransform newTransform)
 Moves the nodes in this graph.
 
void ReplaceTile (int x, int z, Int3[] verts, int[] tris)
 Replace tile at index with nodes created from specified navmesh.
 
void ReplaceTile (int x, int z, int w, int d, Int3[] verts, int[] tris)
 Replaces a tile with a new mesh.
 
void StartBatchTileUpdate ()
 Start batch updating of tiles.
 
- Public Member Functions inherited from NavGraph
virtual int CountNodes ()
 Number of nodes in the graph.
 
NNInfoInternal GetNearest (Vector3 position)
 Returns the nearest node to a position using the default NNConstraint.
 
NNInfoInternal GetNearest (Vector3 position, NNConstraint constraint)
 Returns the nearest node to a position using the specified NNConstraint.
 
void GetNodes (System.Func< GraphNode, bool > action)
 Calls a delegate with all nodes in the graph until the delegate returns false.
 
virtual void OnDrawGizmos (RetainedGizmos gizmos, bool drawNodes)
 Draw gizmos for the graph.
 
void RelocateNodes (Matrix4x4 oldMatrix, Matrix4x4 newMatrix)
 Moves nodes in this graph.
 
void Scan ()
 Scan the graph.
 
void ScanGraph ()
 Scan the graph.
 
void SetMatrix (Matrix4x4 m)
 Use to set both matrix and inverseMatrix at the same time.
 
- Public Member Functions inherited from IGraphInternals
void DeserializeExtraInfo (GraphSerializationContext ctx)
 
void DeserializeSettingsCompatibility (GraphSerializationContext ctx)
 
void DestroyAllNodes ()
 
void OnDestroy ()
 
void PostDeserialization (GraphSerializationContext ctx)
 
IEnumerable< ProgressScanInternal ()
 
void SerializeExtraInfo (GraphSerializationContext ctx)
 
- Public Member Functions inherited from INavmesh
void GetNodes (System.Action< GraphNode > del)
 
- Public Member Functions inherited from INavmeshHolder
void GetTileCoordinates (int tileIndex, out int x, out int z)
 Transforms coordinates from graph space to world space.
 
Int3 GetVertex (int i)
 Position of vertex number i in the world.
 
int GetVertexArrayIndex (int index)
 
Int3 GetVertexInGraphSpace (int i)
 Position of vertex number i in coordinates local to the graph.
 

Static Public Member Functions

static int GetTileIndex (int index)
 Tile index from a vertex index.
 
static bool Linecast (NavmeshBase graph, Vector3 origin, Vector3 end, GraphNode hint, out GraphHitInfo hit)
 Returns if there is an obstacle between origin and end on the graph.
 
static bool Linecast (NavmeshBase graph, Vector3 origin, Vector3 end, GraphNode hint, out GraphHitInfo hit, List< GraphNode > trace)
 Returns if there is an obstacle between origin and end on the graph.
 

Public Attributes

Vector3 forcedBoundsSize = new Vector3(100, 40, 100)
 Size of the bounding box.
 
bool nearestSearchOnlyXZ
 Perform nearest node searches in XZ space only.
 
System.Action< NavmeshTile[]> OnRecalculatedTiles
 Called when tiles have been completely recalculated.
 
bool showMeshOutline = true
 Show an outline of the polygons in the Unity Editor.
 
bool showMeshSurface
 Show the surface of the navmesh.
 
bool showNodeConnections
 Show the connections between the polygons in the Unity Editor.
 
const int TileIndexMask = 0x7FFFF
 
const int TileIndexOffset = 12
 
int tileXCount
 Number of tiles along the X-axis.
 
int tileZCount
 Number of tiles along the Z-axis.
 
GraphTransform transform = new GraphTransform(Matrix4x4.identity)
 Determines how the graph transforms graph space to world space.
 
const int VertexIndexMask = 0xFFF
 
- Public Attributes inherited from NavGraph
AstarPath active
 Reference to the AstarPath object in the scene.
 
bool drawGizmos = true
 Enable to draw gizmos in the Unity scene view.
 
uint graphIndex
 Index of the graph, used for identification purposes.
 
Guid guid
 Used as an ID of the graph, considered to be unique.
 
bool infoScreenOpen
 Used in the editor to check if the info screen is open.
 
uint initialPenalty
 Default penalty to apply to all nodes.
 
Matrix4x4 inverseMatrix = Matrix4x4.identity
 Inverse of matrix.
 
Matrix4x4 matrix = Matrix4x4.identity
 A matrix for translating/rotating/scaling the graph.
 
string name
 Name of the graph.
 
bool open
 Is the graph open in the editor.
 

Protected Member Functions

void ClearTiles (int x, int z, int w, int d)
 Clear all tiles within the rectangle with one corner at (x,z), width w and depth d.
 
void ConnectTiles (NavmeshTile tile1, NavmeshTile tile2)
 Generate connections between the two tiles.
 
void ConnectTileWithNeighbours (NavmeshTile tile, bool onlyUnflagged=false)
 
TriangleMeshNode[] CreateNodes (int[] tris, int tileIndex, uint graphIndex)
 
override void DeserializeExtraInfo (GraphSerializationContext ctx)
 Deserializes graph type specific node data.
 
void FillWithEmptyTiles ()
 Fills graph with tiles created by NewEmptyTile.
 
NavmeshTile NewEmptyTile (int x, int z)
 Creates a single new empty tile.
 
override void OnDestroy ()
 Function for cleaning up references.
 
override void PostDeserialization (GraphSerializationContext ctx)
 Called after all deserialization has been done for all graphs.
 
void RemoveConnectionsFromTile (NavmeshTile tile)
 
void RemoveConnectionsFromTo (NavmeshTile a, NavmeshTile b)
 
override void SerializeExtraInfo (GraphSerializationContext ctx)
 Serializes Node Info.
 
- Protected Member Functions inherited from NavGraph
virtual void DeserializeSettingsCompatibility (GraphSerializationContext ctx)
 An old format for serializing settings.
 
virtual void DestroyAllNodes ()
 Destroys all nodes in the graph.
 
void DrawUnwalkableNodes (float size)
 
abstract IEnumerable< ProgressScanInternal ()
 Internal method to scan the graph.
 

Static Protected Member Functions

static void CreateNodeConnections (TriangleMeshNode[] nodes)
 Create connections between all nodes.
 

Protected Attributes

NavmeshTile[] tiles
 All tiles.
 

Properties

abstract float MaxTileConnectionEdgeDistance [get]
 Maximum (vertical) distance between the sides of two nodes for them to be connected across a tile edge.
 
abstract float TileWorldSizeX [get]
 Size of a tile in world units along the X axis.
 
abstract float TileWorldSizeZ [get]
 Size of a tile in world units along the Z axis.
 
GraphTransform ITransformedGraph. transform [get]
 
- Properties inherited from NavGraph
bool exists [get]
 True if the graph exists, false if it has been destroyed.
 
- Properties inherited from ITransformedGraph
GraphTransform transform [get]
 

Private Member Functions

void CreateNavmeshSurfaceVisualization (NavmeshTile tile, GraphGizmoHelper helper)
 Creates a mesh of the surfaces of the navmesh for use in OnDrawGizmos in the editor.
 

Static Private Member Functions

static void CreateNavmeshOutlineVisualization (NavmeshTile tile, GraphGizmoHelper helper)
 Creates an outline of the navmesh for use in OnDrawGizmos in the editor.
 

Private Attributes

bool batchTileUpdate
 Currently updating tiles in a batch.
 
List< int > batchUpdatedTiles = new List<int>()
 List of tiles updating during batch.
 

Static Private Attributes

static readonly NNConstraint NNConstraintDistanceXZ = new NNConstraint { distanceXZ = true }
 

Member Function Documentation

abstract GraphTransform CalculateTransform ( )
pure virtual

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

Does not update the transform field.

See Also
RelocateNodes(GraphTransform)

Implemented in RecastGraph, and NavMeshGraph.

void ClearTiles ( int  x,
int  z,
int  w,
int  d 
)
protected

Clear all tiles within the rectangle with one corner at (x,z), width w and depth d.

void ConnectTiles ( NavmeshTile  tile1,
NavmeshTile  tile2 
)
protected

Generate connections between the two tiles.

The tiles must be adjacent.

void ConnectTileWithNeighbours ( NavmeshTile  tile,
bool  onlyUnflagged = false 
)
protected
static void CreateNavmeshOutlineVisualization ( NavmeshTile  tile,
GraphGizmoHelper  helper 
)
staticprivate

Creates an outline of the navmesh for use in OnDrawGizmos in the editor.

void CreateNavmeshSurfaceVisualization ( NavmeshTile  tile,
GraphGizmoHelper  helper 
)
private

Creates a mesh of the surfaces of the navmesh for use in OnDrawGizmos in the editor.

static void CreateNodeConnections ( TriangleMeshNode[]  nodes)
staticprotected

Create connections between all nodes.

Version
Since 3.7.6 the implementation is thread safe
TriangleMeshNode [] CreateNodes ( int[]  tris,
int  tileIndex,
uint  graphIndex 
)
protected
override void DeserializeExtraInfo ( GraphSerializationContext  ctx)
protectedvirtual

Deserializes graph type specific node data.

See Also
SerializeExtraInfo

Reimplemented from NavGraph.

void EndBatchTileUpdate ( )

End batch updating of tiles.

During batch updating, tiles will not be connected if they are updating with ReplaceTile. When ending batching, all affected tiles will be connected. This is faster than not using batching.

void FillWithEmptyTiles ( )
protected

Fills graph with tiles created by NewEmptyTile.

override NNInfoInternal GetNearest ( Vector3  position,
NNConstraint  constraint,
GraphNode  hint 
)
virtual

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

Parameters
positionThe position to try to find a close node to
hintCan be passed to enable some graph generators to find the nearest node faster.
constraintCan for example tell the function to try to return a walkable node. If you do not get a good node back, consider calling GetNearestForce.

Reimplemented from NavGraph.

override NNInfoInternal GetNearestForce ( Vector3  position,
NNConstraint  constraint 
)
virtual

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

Returns
an NNInfo. This method will only return an empty NNInfo if there are no nodes which comply with the specified constraint.

Reimplemented from NavGraph.

override void GetNodes ( System.Action< GraphNode action)
virtual

Calls a delegate with all nodes in the graph.

This is the primary way of iterating through all nodes in a graph.

Do not change the graph structure inside the delegate.

var gg = AstarPath.active.data.gridGraph;
gg.GetNodes(node => {
// Here is a node
Debug.Log("I found a node at position " + (Vector3)node.position);
});

If you want to store all nodes in a list you can do this

var gg = AstarPath.active.data.gridGraph;
List<GraphNode> nodes = new List<GraphNode>();
gg.GetNodes((System.Action<GraphNode>)nodes.Add);

Implements NavGraph.

NavmeshTile GetTile ( int  x,
int  z 
)

Tile at the specified x, z coordinate pair.

The first tile is at (0,0), the last tile at (tileXCount-1, tileZCount-1).

var graph = AstarPath.active.data.recastGraph;
int tileX = 5;
int tileZ = 8;
NavmeshTile tile = graph.GetTile(tileX, tileZ);
for (int i = 0; i < tile.nodes.Length; i++) {
// ...
}
// or you can access the nodes like this:
tile.GetNodes(node => {
// ...
});
Bounds GetTileBounds ( IntRect  rect)

Returns an XZ bounds object with the bounds of a group of tiles.

The bounds object is defined in world units.

Bounds GetTileBounds ( int  x,
int  z,
int  width = 1,
int  depth = 1 
)

Returns an XZ bounds object with the bounds of a group of tiles.

The bounds object is defined in world units.

Bounds GetTileBoundsInGraphSpace ( IntRect  rect)
Bounds GetTileBoundsInGraphSpace ( int  x,
int  z,
int  width = 1,
int  depth = 1 
)

Returns an XZ bounds object with the bounds of a group of tiles in graph space.

void GetTileCoordinates ( int  tileIndex,
out int  x,
out int  z 
)

Tile coordinates from a tile index.

Int2 GetTileCoordinates ( Vector3  position)

Returns the tile coordinate which contains the specified position.

It is not necessarily a valid tile (i.e it could be out of bounds).

static int GetTileIndex ( int  index)
static

Tile index from a vertex index.

NavmeshTile [] GetTiles ( )

All tiles.

Warning
Do not modify this array
IntRect GetTouchingTiles ( Bounds  bounds)

Returns a rect containing the indices of all tiles touching the specified bounds.

IntRect GetTouchingTilesInGraphSpace ( Rect  rect)

Returns a rect containing the indices of all tiles touching the specified bounds.

Parameters
rectGraph space rectangle (in graph space all tiles are on the XZ plane regardless of graph rotation and other transformations, the first tile has a corner at the origin)
IntRect GetTouchingTilesRound ( Bounds  bounds)

Returns a rect containing the indices of all tiles by rounding the specified bounds to tile borders.

This is different from GetTouchingTiles in that the tiles inside the rectangle returned from this method may not contain the whole bounds, while that is guaranteed for GetTouchingTiles.

Int3 GetVertex ( int  index)

Vertex coordinate for the specified vertex index.

Exceptions
IndexOutOfRangeExceptionif the vertex index is invalid.
NullReferenceExceptionif the tile the vertex is in is not calculated.
See Also
NavmeshTile.GetVertex
int GetVertexArrayIndex ( int  index)
Int3 GetVertexInGraphSpace ( int  index)

Vertex coordinate in graph space for the specified vertex index.

bool Linecast ( Vector3  origin,
Vector3  end 
)

Returns if there is an obstacle between origin and end on the graph.

This is not the same as Physics.Linecast, this function traverses the graph and looks for collisions instead of checking for collider intersection.

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
bool Linecast ( Vector3  origin,
Vector3  end,
GraphNode  hint,
out GraphHitInfo  hit 
)

Returns if there is an obstacle between origin and end on the graph.

Parameters
[in]originPoint to linecast from
[in]endPoint to linecast to
[out]hitContains info on what was hit, see GraphHitInfo
[in]hintYou need to pass the node closest to the start point

This is not the same as Physics.Linecast, this function traverses the graph and looks for collisions instead of checking for collider intersection.

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
bool Linecast ( Vector3  origin,
Vector3  end,
GraphNode  hint 
)

Returns if there is an obstacle between origin and end on the graph.

Parameters
[in]originPoint to linecast from
[in]endPoint to linecast to
[in]hintYou need to pass the node closest to the start point

This is not the same as Physics.Linecast, this function traverses the graph and looks for collisions instead of checking for collider intersection.

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
bool Linecast ( Vector3  origin,
Vector3  end,
GraphNode  hint,
out GraphHitInfo  hit,
List< GraphNode trace 
)

Returns if there is an obstacle between origin and end on the graph.

Parameters
[in]originPoint to linecast from
[in]endPoint to linecast to
[out]hitContains info on what was hit, see GraphHitInfo
[in]hintYou need to pass the node closest to the start point
traceIf a list is passed, then it will be filled with all nodes the linecast traverses

This is not the same as Physics.Linecast, this function traverses the graph and looks for collisions instead of checking for collider intersection.

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
static bool Linecast ( NavmeshBase  graph,
Vector3  origin,
Vector3  end,
GraphNode  hint,
out GraphHitInfo  hit 
)
static

Returns if there is an obstacle between origin and end on the graph.

Parameters
[in]graphThe graph to perform the search on
[in]originPoint to start from
[in]endPoint to linecast to
[out]hitContains info on what was hit, see GraphHitInfo
[in]hintYou need to pass the node closest to the start point, if null, a search for the closest node will be done

This is not the same as Physics.Linecast, this function traverses the graph and looks for collisions instead of checking for collider intersection.

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
static bool Linecast ( NavmeshBase  graph,
Vector3  origin,
Vector3  end,
GraphNode  hint,
out GraphHitInfo  hit,
List< GraphNode trace 
)
static

Returns if there is an obstacle between origin and end on the graph.

Parameters
[in]graphThe graph to perform the search on
[in]originPoint to start from
[in]endPoint to linecast to
[out]hitContains info on what was hit, see GraphHitInfo
[in]hintYou need to pass the node closest to the start point, if null, a search for the closest node will be done
traceIf a list is passed, then it will be filled with all nodes the linecast traverses

This is not the same as Physics.Linecast, this function traverses the graph and looks for collisions instead of checking for collider intersection.

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
NavmeshTile NewEmptyTile ( int  x,
int  z 
)
protected

Creates a single new empty tile.

override void OnDestroy ( )
protectedvirtual

Function for cleaning up references.

This will be called on the same time as OnDisable on the gameObject which the AstarPath script is attached to (remember, not in the editor). Use for any cleanup code such as cleaning up static variables which otherwise might prevent resources from being collected. Use by creating a function overriding this one in a graph class, but always call base.OnDestroy () in that function. All nodes should be destroyed in this function otherwise a memory leak will arise.

Reimplemented from NavGraph.

override void OnDrawGizmos ( Pathfinding.Util.RetainedGizmos  gizmos,
bool  drawNodes 
)
GraphNode PointOnNavmesh ( Vector3  position,
NNConstraint  constraint 
)

Finds the first node which contains position.

"Contains" is defined as position is inside the triangle node when seen from above. So only XZ space matters. In case of a multilayered environment, which node of the possibly several nodes containing the point is undefined.

Returns null if there was no node containing the point. This serves as a quick check for "is this point on the navmesh or not".

Note that the behaviour of this method is distinct from the GetNearest method. The GetNearest method will return the closest node to a point, which is not necessarily the one which contains it in XZ space.

See Also
GetNearest
override void PostDeserialization ( GraphSerializationContext  ctx)
protectedvirtual

Called after all deserialization has been done for all graphs.

Can be used to set up more graph data which is not serialized

Reimplemented from NavGraph.

override void RelocateNodes ( Matrix4x4  deltaMatrix)
virtual

Moves the nodes in this graph.

Multiplies all node positions by deltaMatrix.

For example if you want to move all your nodes in e.g a point graph 10 units along the X axis from the initial position

var graph = AstarPath.data.pointGraph;
var m = Matrix4x4.TRS (new Vector3(10,0,0), Quaternion.identity, Vector3.one);
graph.RelocateNodes (m);
Note
For grid graphs, navmesh graphs and recast graphs it is recommended to use their custom overloads of the RelocateNodes method which take parameters for e.g center and nodeSize (and additional parameters) instead since they are both easier to use and are less likely to mess up pathfinding.
Warning
This method is lossy for PointGraphs, so calling it many times may cause node positions to lose precision. For example if you set the scale to 0 in one call then all nodes will be scaled/moved to the same point and you will not be able to recover their original positions. The same thing happens for other - less extreme - values as well, but to a lesser degree.

Reimplemented from NavGraph.

void RelocateNodes ( GraphTransform  newTransform)

Moves the nodes in this graph.

Moves all the nodes in such a way that the specified transform is the new graph space to world space transformation for the graph. You usually use this together with the CalculateTransform method.

So for example if you want to move and rotate all your nodes in e.g a recast graph you can do

var graph = AstarPath.data.recastGraph;
graph.rotation = new Vector3(45, 0, 0);
graph.forcedBoundsCenter = new Vector3(20, 10, 10);
var transform = graph.CalculateTransform();
graph.RelocateNodes(transform);

This will move all the nodes to new positions as if the new graph settings had been there from the start.

Note
RelocateNodes(deltaMatrix) is not equivalent to RelocateNodes(new GraphTransform(deltaMatrix)). The overload which takes a matrix multiplies all existing node positions with the matrix while this overload does not take into account the current positions of the nodes.
See Also
CalculateTransform
void RemoveConnectionsFromTile ( NavmeshTile  tile)
protected
void RemoveConnectionsFromTo ( NavmeshTile  a,
NavmeshTile  b 
)
protected
void ReplaceTile ( int  x,
int  z,
Int3[]  verts,
int[]  tris 
)

Replace tile at index with nodes created from specified navmesh.

See Also
StartBatchTileUpdating
void ReplaceTile ( int  x,
int  z,
int  w,
int  d,
Int3[]  verts,
int[]  tris 
)

Replaces a tile with a new mesh.

This will create new nodes and link them to the adjacent tile (unless batching has been started in which case that will be done when batching ends).

The vertices are assumed to be in 'tile space', that is being in a rectangle with one corner at the origin and one at (TileWorldSizeX, 0, TileWorldSizeZ).

Note
The vertex and triangle arrays may be modified and will be stored with the tile data. do not modify them after this method has been called.
override void SerializeExtraInfo ( GraphSerializationContext  ctx)
protectedvirtual

Serializes Node Info.

Should serialize:

  • Base
    • Node Flags
    • Node Penalties
    • Node
  • Node Positions (if applicable)
  • Any other information necessary to load the graph in-game All settings marked with json attributes (e.g JsonMember) have already been saved as graph settings and do not need to be handled here.

It is not necessary for this implementation to be forward or backwards compatible.

See Also

Reimplemented from NavGraph.

void StartBatchTileUpdate ( )

Start batch updating of tiles.

During batch updating, tiles will not be connected if they are updating with ReplaceTile. When ending batching, all affected tiles will be connected. This is faster than not using batching.

Member Data Documentation

bool batchTileUpdate
private

Currently updating tiles in a batch.

List<int> batchUpdatedTiles = new List<int>()
private

List of tiles updating during batch.

Vector3 forcedBoundsSize = new Vector3(100, 40, 100)

Size of the bounding box.

bool nearestSearchOnlyXZ

Perform nearest node searches in XZ space only.

Recomended for single-layered environments. Faster but can be inaccurate esp. in multilayered contexts. You should not use this if the graph is rotated since then the XZ plane no longer corresponds to the ground plane.

This can be important on sloped surfaces. See the image below:

You can also control this using a field on an NNConstraint object.

readonly NNConstraint NNConstraintDistanceXZ = new NNConstraint { distanceXZ = true }
staticprivate
System.Action<NavmeshTile[]> OnRecalculatedTiles

Called when tiles have been completely recalculated.

This is called after scanning the graph and after performing graph updates that completely recalculate tiles (not ones that simply modify e.g penalties). It is not called after NavmeshCut updates.

bool showMeshOutline = true

Show an outline of the polygons in the Unity Editor.

bool showMeshSurface

Show the surface of the navmesh.

bool showNodeConnections

Show the connections between the polygons in the Unity Editor.

const int TileIndexMask = 0x7FFFF
const int TileIndexOffset = 12
NavmeshTile [] tiles
protected

All tiles.

See Also
GetTile
int tileXCount

Number of tiles along the X-axis.

int tileZCount

Number of tiles along the Z-axis.

GraphTransform transform = new GraphTransform(Matrix4x4.identity)

Determines how the graph transforms graph space to world space.

See Also
CalculateTransform
const int VertexIndexMask = 0xFFF

Property Documentation

abstract float MaxTileConnectionEdgeDistance
getprotected

Maximum (vertical) distance between the sides of two nodes for them to be connected across a tile edge.

When tiles are connected to each other, the nodes sometimes do not line up perfectly so some allowance must be made to allow tiles that do not match exactly to be connected with each other.

abstract float TileWorldSizeX
get

Size of a tile in world units along the X axis.

abstract float TileWorldSizeZ
get

Size of a tile in world units along the Z axis.

GraphTransform ITransformedGraph. transform
getprivate

The documentation for this class was generated from the following file: