A* Pathfinding Project
3.1.4
The A* Pathfinding Project for Unity 3D
|
Generates graphs based on navmeshes. More...
Public Member Functions | |
void | AddPortal (Node n1, Node n2, List< Vector3 > left, List< Vector3 > right) |
void | BuildFunnelCorridor (List< Node > path, int startIndex, int endIndex, List< Vector3 > left, List< Vector3 > right) |
bool | ContainsPoint (MeshNode node, Vector3 pos) |
Returns if the point is inside the node in XZ space. | |
override Node[] | CreateNodes (int number) |
Creates a number of nodes with the correct type for the graph. | |
override void | DeserializeExtraInfo (byte[] bytes) |
Deserializes graph type specific node data. | |
void | DeSerializeNodes (Node[] nodes, AstarSerializer serializer) |
void | DeSerializeSettings (AstarSerializer serializer) |
void | GenerateMatrix () |
override NNInfo | GetNearest (Vector3 position, NNConstraint constraint, Node hint) |
Returns the nearest node to a position using the specified NNConstraint. | |
override NNInfo | GetNearestForce (Vector3 position, NNConstraint constraint) |
This performs a linear search through all polygons returning the closest one. | |
bool | Linecast (Vector3 origin, Vector3 end) |
Returns if origin is visible from end on the graph. | |
bool | Linecast (Vector3 origin, Vector3 end, Node hint, out GraphHitInfo hit) |
Returns if origin is visible from end on the graph. | |
bool | Linecast (Vector3 origin, Vector3 end, Node hint) |
Returns if end is visible from origin on the graph. | |
override void | OnDrawGizmos (bool drawNodes) |
void | PostProcess () |
override void | RelocateNodes (Matrix4x4 oldMatrix, Matrix4x4 newMatrix) |
Relocates the nodes to match the newMatrix. | |
void | Scan (string objMeshPath) |
Scans the graph using the path to an .obj mesh. | |
override void | Scan () |
Scans the graph, called from AstarPath.Scan Override this function to implement custom scanning logic | |
override byte[] | SerializeExtraInfo () |
Serializes graph type specific node data. | |
void | SerializeNodes (Node[] nodes, AstarSerializer serializer) |
void | SerializeSettings (AstarSerializer serializer) |
void | Sort (Vector3[] a) |
void | UpdateArea (GraphUpdateObject o) |
Public Member Functions inherited from NavGraph | |
virtual void | Awake () |
This will be called on the same time as Awake on the gameObject which the AstarPath script is attached to. | |
NNInfo | GetNearest (Vector3 position) |
Returns the nearest node to a position using the default NNConstraint. | |
NNInfo | GetNearest (Vector3 position, NNConstraint constraint) |
Returns the nearest node to a position using the specified NNConstraint. | |
bool | InSearchTree (Node node, Path path) |
Returns if the node is in the search tree of the path. | |
virtual Color | NodeColor (Node node, NodeRunData data) |
virtual void | OnDestroy () |
Function for cleaning up references. | |
virtual void | PostDeserialization () |
Called after all deserialization has been done for all graphs. | |
void | SafeOnDestroy () |
SafeOnDestroy should be used when there is a risk that the pathfinding is searching through this graph when called | |
void | ScanGraph () |
Consider using AstarPath.Scan () instead since this function might screw things up if there is more than one graph. | |
Public Member Functions inherited from ISerializableGraph | |
Node[] | CreateNodes (int num) |
void | DeSerializeNodes (Node[] nodes, AstarSerializer serializer) |
void | SerializeNodes (Node[] nodes, AstarSerializer serializer) |
Public Member Functions inherited from ISerializableObject | |
void | DeSerializeSettings (AstarSerializer serializer) |
Called to deserialize the object. | |
void | SerializeSettings (AstarSerializer serializer) |
Called to serialize the object. | |
Public Member Functions inherited from IUpdatableGraph | |
void | UpdateArea (GraphUpdateObject o) |
Updates an area using the specified GraphUpdateObject. | |
Public Member Functions inherited from IFunnelGraph | |
void | AddPortal (Node n1, Node n2, List< Vector3 > left, List< Vector3 > right) |
Add the portal between node n1 and n2 to the funnel corridor. | |
void | BuildFunnelCorridor (List< Node > path, int sIndex, int eIndex, List< Vector3 > left, List< Vector3 > right) |
Public Member Functions inherited from IRaycastableGraph | |
bool | Linecast (Vector3 start, Vector3 end) |
bool | Linecast (Vector3 start, Vector3 end, Node hint) |
bool | Linecast (Vector3 start, Vector3 end, Node hint, out GraphHitInfo hit) |
Static Public Member Functions | |
static void | BuildFunnelCorridor (INavmesh graph, List< Node > path, int startIndex, int endIndex, List< Vector3 > left, List< Vector3 > right) |
static Vector3 | ClosestPointOnNode (MeshNode node, Int3[] vertices, Vector3 pos) |
Returns the closest point of the node. | |
static bool | ContainsPoint (MeshNode node, Vector3 pos, Int3[] vertices) |
Returns if the point is inside the node in XZ space. | |
static void | DeserializeMeshNodes (INavmesh graph, Node[] nodes, byte[] bytes) |
static void | DeSerializeMeshNodes (INavmesh graph, Node[] nodes, AstarSerializer serializer) |
static void | GenerateNodes (NavGraph graph, Vector3[] vectorVertices, int[] triangles, out Vector3[] originalVertices, out Int3[] vertices) |
Generates a navmesh. | |
static NNInfo | GetNearest (INavmesh graph, Node[] nodes, Vector3 position, NNConstraint constraint, bool accurateNearestNode) |
static NNInfo | GetNearestForce (Node[] nodes, Int3[] vertices, Vector3 position, NNConstraint constraint, bool accurateNearestNode) |
This performs a linear search through all polygons returning the closest one. | |
static NNInfo | GetNearestForceBoth (Node[] nodes, Int3[] vertices, Vector3 position, NNConstraint constraint, bool accurateNearestNode) |
This performs a linear search through all polygons returning the closest one. | |
static bool | Linecast (INavmesh graph, Vector3 tmp_origin, Vector3 tmp_end, Node hint, bool thick, float thickness, out GraphHitInfo hit) |
Returns if _b is visible from _a on the graph. | |
static void | RebuildBBTree (NavGraph graph) |
Rebuilds the BBTree on a NavGraph. | |
static byte[] | SerializeMeshNodes (INavmesh graph, Node[] nodes) |
static void | SerializeMeshNodes (INavmesh graph, Node[] nodes, AstarSerializer serializer) |
static void | UpdateArea (GraphUpdateObject o, NavGraph graph) |
Public Attributes | |
bool | accurateNearestNode = true |
More accurate nearest node queries. | |
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. | |
int[] | triangles |
Public Attributes inherited from NavGraph | |
byte[] | _sguid |
Used to store the guid value. | |
AstarPath | active |
Reference to the AstarPath object in the scene. | |
bool | drawGizmos = true |
bool | infoScreenOpen |
Used in the editor to check if the info screen is open. | |
uint | initialPenalty = 0 |
Matrix4x4 | matrix |
A matrix for translating/rotating/scaling the graph. | |
string | name |
Node[] | nodes |
All nodes this graph contains. | |
bool | open |
Is the graph open in the editor | |
Properties | |
BBTree | bbTree [get, set] |
Int3[] | vertices [get, set] |
Properties inherited from NavGraph | |
Guid | guid [get, set] |
Used as an ID of the graph, considered to be unique. | |
Matrix4x4 | inverseMatrix [get] |
Properties inherited from INavmesh | |
BBTree | bbTree [get, set] |
Bounding Box Tree. | |
Int3[] | vertices [get, set] |
Private Attributes | |
BBTree | _bbTree |
Bounding Box Tree. | |
Matrix4x4 | _originalMatrix |
Int3[] | _vertices |
Vector3[] | originalVertices |
Generates graphs based on navmeshes.
Navmeshes are meshes where each polygon define 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 of their smaller size to describe the same area (compared to grid graphs).
|
virtual |
Creates a number of nodes with the correct type for the graph.
This should not set the nodes array, only return the nodes. Called by graph generators and when deserializing a graph with nodes. Override this function if you do not use the default Pathfinding::Node class.
Reimplemented from NavGraph.
|
virtual |
|
static |
Generates a navmesh.
Based on the supplied vertices and triangles. Memory usage is about O(n)
|
virtual |
Returns the nearest node to a position using the specified NNConstraint.
position | The position to try to find a close node to |
hint | Can be passed to enable some graph generators to find the nearest node faster. |
constraint | Can 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.
|
virtual |
This performs a linear search through all polygons returning the closest one.
This is usually only called in the Free version of the A* Pathfinding Project since the Pro one supports BBTrees and will do another query
Reimplemented from NavGraph.
|
static |
This performs a linear search through all polygons returning the closest one.
This will fill the NNInfo with .node for the closest node not necessarily complying with the NNConstraint, and .constrainedNode with the closest node complying with the NNConstraint.
bool Linecast | ( | Vector3 | origin, |
Vector3 | end | ||
) |
Returns if origin is visible from 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.
bool Linecast | ( | Vector3 | origin, |
Vector3 | end, | ||
Node | hint, | ||
out GraphHitInfo | hit | ||
) |
Returns if origin is visible from end on the graph.
[in] | origin | Point to linecast from |
[in] | end | Point to linecast to |
[out] | hit | Contains info on what was hit, see GraphHitInfo |
[in] | hint | You 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.
|
bool Linecast | ( | Vector3 | origin, |
Vector3 | end, | ||
Node | hint | ||
) |
Returns if end is visible from origin on the graph.
[in] | origin | Point to linecast from |
[in] | end | Point to linecast to |
[in] | hint | You 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.
|
|
static |
Returns if _b is visible from _a on the graph.
[in] | graph | The graph to perform the search on |
[in] | tmp_origin | Point to start from |
[in] | tmp_end | Point to linecast to |
[out] | hit | Contains info on what was hit, see GraphHitInfo |
[in] | hint | You need to pass the node closest to the start point |
[in] | thick | An experimental feature can be enabled to use thick linecasts, does not always work as expected |
[in] | thickness | Thickness of the thick linecast This is not the same as Physics.Linecast, this function traverses the graph and looks for collisions instead of checking for collider intersection.
|
|
static |
Rebuilds the BBTree on a NavGraph.
|
virtual |
Relocates the nodes to match the newMatrix.
The "oldMatrix" variable can be left out in this function call (only for this graph generator) since it is not used
Reimplemented from NavGraph.
|
virtual |
Scans the graph, called from AstarPath.Scan Override this function to implement custom scanning logic
Implements NavGraph.
|
virtual |
Serializes graph type specific node data.
This function can be overriden to serialize extra node information (or graph information for that matter) which cannot be serialized using the standard serialization. Serialize the data in any way you want and return a byte array. When loading, the exact same byte array will be passed to the DeserializeExtraInfo function.
These functions will only be called if node serialization is enabled.
If null is returned from this function, the DeserializeExtraInfo function will not be called on load.
Reimplemented from NavGraph.
|
private |
Bounding Box Tree.
Enables really fast lookups of nodes.
bool accurateNearestNode = true |
More accurate nearest node queries.
When on, looks for the closest point on every triangle instead of if point is inside the node triangle in XZ space. This is slower, but a lot better if your mesh contains overlaps (e.g bridges over other areas of the mesh). Note that for maximum effect the Full Get Nearest Node Search setting should be toggled in A* Inspector Settings.