Skip to main content


Showing posts from August, 2017

Adventure Game #003 A* Pathfinding (Version 2)

Following the previous post (here) The AstarPathfinding package is now wrapped up.
I added the following features:

1) Get shortest path with Gameobjects
2) Get shortest path with AstarNodes
3) Return null if end point is unreachable
4) AstarPathfinding is now static
5) Added summaries to the methods for ease of use
6) removed char[,] references.

1) Get shortest path with Gameobjects
The tiles on the game all have a component "AstarTileNode" and have the following members:

+ public enum AstarNodeState { Open, Closed, Start, End}
+ public AstarNodeState CurrentNodeState

///<para>Takes a array of Gameobjects with Component AstarNode and returns a
///recursive node path of the shortest path</para>
///<para>Returns: AstarNode shortest path node, null is no path</para>
public static AstarNode GetShortestPath(GameObject[] gos) {
    List<AstarNode> nodes = new List<AstarNode>();
    foreach(var n in gos) {
        var wsn =…