A* Pathfinding Project
4.1.0
The A* Pathfinding Project for Unity 3D
|
Generates graphs based on navmeshes. More...
Generates graphs based on navmeshes.
Navmeshes are meshes where each triangle defines a walkable area. These are great because the AI can get so much more information on how it can walk. Polygons instead of points mean that the funnel smoother can produce really nice looking paths and the graphs are also really fast to search and have a low memory footprint because fewer nodes are usually needed to describe the same area compared to grid graphs.
Public Member Functions | |
override GraphTransform | CalculateTransform () |
Returns a new transform which transforms graph space to world space. | |
void | ScanInternal (string objMeshPath) |
Scans the graph using the path to an .obj mesh. | |
![]() | |
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. | |
![]() | |
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. | |
![]() | |
void | DeserializeExtraInfo (GraphSerializationContext ctx) |
void | DeserializeSettingsCompatibility (GraphSerializationContext ctx) |
void | DestroyAllNodes () |
void | OnDestroy () |
void | PostDeserialization (GraphSerializationContext ctx) |
IEnumerable< Progress > | ScanInternal () |
void | SerializeExtraInfo (GraphSerializationContext ctx) |
![]() | |
void | GetNodes (System.Action< GraphNode > del) |
![]() | |
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. | |
![]() | |
GraphUpdateThreading | CanUpdateAsync (GraphUpdateObject o) |
void | UpdateArea (GraphUpdateObject o) |
Updates an area using the specified GraphUpdateObject. | |
void | UpdateAreaInit (GraphUpdateObject o) |
May be called on the Unity thread before starting the update. | |
void | UpdateAreaPost (GraphUpdateObject o) |
May be called on the Unity thread after executing the update. | |
Static Public Member Functions | |
static void | UpdateArea (GraphUpdateObject o, INavmeshHolder graph) |
![]() | |
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 | offset |
Offset in world space. | |
Vector3 | rotation |
Rotation in degrees. | |
float | scale = 1 |
Scale of the graph. | |
Mesh | sourceMesh |
Mesh to construct navmesh from. | |
![]() | |
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 |
![]() | |
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 | |
override void | DeserializeSettingsCompatibility (GraphSerializationContext ctx) |
An old format for serializing settings. | |
override IEnumerable< Progress > | ScanInternal () |
Internal method to scan the graph. | |
![]() | |
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. | |
![]() | |
virtual void | DestroyAllNodes () |
Destroys all nodes in the graph. | |
void | DrawUnwalkableNodes (float size) |
Properties | |
override float | MaxTileConnectionEdgeDistance [get] |
override float | TileWorldSizeX [get] |
override float | TileWorldSizeZ [get] |
![]() | |
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] |
![]() | |
bool | exists [get] |
True if the graph exists, false if it has been destroyed. | |
![]() | |
GraphTransform | transform [get] |
Private Member Functions | |
GraphUpdateThreading IUpdatableGraph. | CanUpdateAsync (GraphUpdateObject o) |
void IUpdatableGraph. | UpdateArea (GraphUpdateObject o) |
void IUpdatableGraph. | UpdateAreaInit (GraphUpdateObject o) |
void IUpdatableGraph. | UpdateAreaPost (GraphUpdateObject o) |
Additional Inherited Members | |
![]() | |
static void | CreateNodeConnections (TriangleMeshNode[] nodes) |
Create connections between all nodes. | |
![]() | |
NavmeshTile[] | tiles |
All tiles. | |
|
virtual |
Returns a new transform which transforms graph space to world space.
Does not update the transform field.
Implements NavmeshBase.
|
private |
|
protectedvirtual |
An old format for serializing settings.
Reimplemented from NavGraph.
void ScanInternal | ( | string | objMeshPath | ) |
Scans the graph using the path to an .obj mesh.
|
protectedvirtual |
Internal method to scan the graph.
Called from AstarPath.ScanAsync. Override this function to implement custom scanning logic. Progress objects can be yielded to show progress info in the editor and to split up processing over several frames when using async scanning.
Implements NavGraph.
|
private |
|
static |
|
private |
|
private |
Vector3 offset |
Offset in world space.
Vector3 rotation |
Rotation in degrees.
float scale = 1 |
Scale of the graph.
Mesh sourceMesh |
Mesh to construct navmesh from.
|
getprotected |
|
get |
|
get |