A* Pathfinding Project  3.1.4
The A* Pathfinding Project for Unity 3D
 All Classes Namespaces Files Functions Variables Enumerations Properties Groups Pages
PathUtilities Class Reference

Contains useful functions for working with paths and nodes. More...

Static Public Member Functions

static List< NodeGetReachableNodes (Node seed, int tagMask=-1)
 Returns all nodes reachable from the seed node.
 
static bool IsPathPossible (Node n1, Node n2)
 Returns if there is a walkable path from n1 to n2.
 
static bool IsPathPossible (List< Node > nodes)
 Returns if there are walkable paths between all nodes.
 

Detailed Description

Contains useful functions for working with paths and nodes.

This class works a lot with the Node class, a useful function to get nodes is AstarPath.GetNearest.

See Also
AstarPath.GetNearest
Pathfinding.Utils.GraphUpdateUtilities
Since
Added in version 3.2

Member Function Documentation

static List<Node> GetReachableNodes ( Node  seed,
int  tagMask = -1 
)
static

Returns all nodes reachable from the seed node.

This function performs a BFS (breadth-first-search) or flood fill of the graph and returns all nodes which can be reached from the seed node. In almost all cases this will be identical to returning all nodes which have the same area as the seed node. In the editor areas are displayed as different colors of the nodes. The only case where it will not be so is when there is a one way path from some part of the area to the seed node but no path from the seed node to that part of the graph.

The returned list is sorted by node distance from the seed node i.e distance is measured in the number of nodes the shortest path from seed to that node would pass through. Note that the distance measurement does not take heuristics, penalties or tag penalties.

Depending on the number of reachable nodes, this function can take quite some time to calculate so don't use it too often or it might affect the framerate of your game.

Parameters
seedThe node to start the search from
tagMaskOptional mask for tags. This is a bitmask.
Returns
A List<Node> containing all nodes reachable from the seed node. For better memory management the returned list should be pooled, see Pathfinding.Util.ListPool
static bool IsPathPossible ( Node  n1,
Node  n2 
)
static

Returns if there is a walkable path from n1 to n2.

If you are making changes to the graph, areas must first be recaculated using FloodFill()

Note
This might return true for small areas even if there is no possible path if AstarPath.minAreaSize is greater than zero (0). So when using this, it is recommended to set AstarPath.minAreaSize to 0. (A* Inspector -> Settings -> Pathfinding)
See Also
AstarPath.GetNearest

+ Here is the caller graph for this function:

static bool IsPathPossible ( List< Node nodes)
static

Returns if there are walkable paths between all nodes.

If you are making changes to the graph, areas must first be recaculated using FloodFill()

Note
This might return true for small areas even if there is no possible path if AstarPath.minAreaSize is greater than zero (0). So when using this, it is recommended to set AstarPath.minAreaSize to 0. (A* Inspector -> Settings -> Pathfinding)
See Also
AstarPath.GetNearest

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