I’ve been wanting to get into game dev for quite a while now, but unfortunately I’m not a terribly creative person. So I decided to leave the creative aspect to the game designers and just focus on making features. Therefore I decided to start with A*. I certainly have made the same mistake that a lot of other fledgling devs have made where I would bite off more than I could chew for a single dev. Recently I decided that enough was enough, it’s time to finally publish something to show off what I do know.

One of the starting projects for learning a new language that I’ve been using for several years now is to program A* pathfinding over a regular grid. This is a relatively simple algorithm, that I think is just complex enough to require the usage of several aspects of any language, from classes to functions, and having a look at some of the provided structures. For example, C# has a sorted list, but it requires that the objects being inserted implement the IComparable interface to work properly. C#’s documentation turns out to be pretty good and fairly easily navigated most of the time.

Most of this project was geared towards figuring out Unity. I had very little experience actually developing with Unity before this, just following tutorials mainly. But now I was forced to do some of my own exploration. One thing I wanted to try was some UI using toggles. I found out through this that UI requires a canvas to be rendered. I also wanted to have more of a radio button action where only one toggle could be on at a time. This led me to Toggle Groups, something that’s kind of weird in my opinion since it requires it’s own separate object within the scene.

Overall, I learned a lot about developing in Unity as a programmer during this project. The workflow is kind of interesting since this is really the first time I’ve had to use two very different and very unique programs in my workflow and having to constantly switch between them. I also learned quite a bit about just how much I can manipulate objects through scripting in Unity. It’s actually quite flexible which is really nice for me since I mostly work with code.

Finally, there are some things that I want to add to the executable. First of all, I want to different heuristics under their own toggle group. They can help show off the weaknesses and strengths of A*. Since A* requires a consistent heuristic, adding a couple non-consistent heuristics will provide intriguing results. Lastly, there are other pathfinding algorithms besides A*. Depth first search, breadth first search, Dijkstra’s algorithm, and Jump Point Search all come to mind as algorithms useful on a regular grid that don’t require to much preprocessing. (I’ve programmed an algorithm called Subgoal graphs, but that algorithm requires an extreme amount of preprocessing to be effective at all. ) By adding these two ideas separately they can then be mixed fairly easily. One thing that I do want to find out is how function pointers work in C#. I do want to be able to practice and learn more about C# as well.

You can check out and download the project to run it yourself from my github page at https://github.com/ispooner/UnityAStar