Simple A* pathfinding algorithm implemented!

For my 3D Supergirl game I needed to implement a pathfinding algorithm for the AI in the game to allow the enemies to find the player. For a bit of fun I thought I would have a go at writing my own implementation!

I have used the quads in the scene as my own nav points. The red cells are inaccessible. Once the path has been found the cells in the path light up and you can see the character will follow the path, ignoring no-go areas.

My implementation uses A*. To calculate my H score, I used the Manhattan algorithm. For the G score I used a value of 10 for the straight cell-cell transitions, and 14 for the diagonal, as in this reference: http://www.policyalmanac.org/games/aStarTutorial.htm.

You can see it in action in the video below!

Leave a Reply

Your email address will not be published. Required fields are marked *