I started programming seriously in college back in 2007.
(Give me a minute while the existential dread over the passage of time cools down a bit.)
Sorry. Anyway, from that point, I must say the most fun I’ve had with programming has been programming AI. Hell, AI is one of the reasons I got into programming in the first place! It always fascinated me, figuring out how games “think” and react. This was mentioned before in my tutorial for the Super Simple State Machine.
There are many different methods to making your game “think”: Decision Trees (Scripting), Navigation Mesh, State Machines, and Pathfinding. Guess which one we’re talking about today!
More specifically, we’re talking about A* (pronounced “Ay-Star”) Pathfinding. To me, this is the grand-daddy of any pathfinding algorithm, or the “baseline.” Because, with this, there are so many different routes you can take with how the result is found or delivered. You can throw a monkey wrench anywhere in the pipeline and get different behavior in your AI to make it seem dumber, smarter, non-linear, or even use it to not just traverse terrain, but maybe dictate what actions are performed – make an A* Decision Tree!
So, lets kick off this multi-part tutorial, and, in the end, we’ll make a simple A* Pathfinding algorithm, with lots of room to grow. This is going to be written for Unity, but the concepts and ideas can be expanded to a number of different platforms.