Back to home

A* Pathfinding (3D)

This project took maybe a day or two total of research + work to complete (time spent working, not from project start to project finish). The core part of the project is the pathfinding script and the actual pathfinding algorithm that I came up with after a bit of research on how the algorithm is supposed to work. It is comprised of two functions, CalculatePath and TraversePath.

When called, the CalculatePath function gets all the neighboring Nodes that are open/walkable and puts them in a list. Then, it calculates the g, h, and f cost of each of these Nodes, sorts them in order of f cost from least to greatest, picks the one with the lowest f cost and sets it as the current Node and adds it to a list called pathNodes. It then repeats this loop until it reaches the end Node. Once the end Node is reached, the TraversePath function walks a game object through each of the Nodes in the pathNodes list until it reaches the end Node.

You can download this project on my Github page here.