A star pathfinding is easy!

If you are like me, you probably have the impostor syndrome. 
And let’s be honest, I’m not good at math and often it’s a hard problem for game dev.

Today I’m going to talk about A* also known as A star pathfinding.

At first, I thought I would not be able to do it myself, so I spent a lot of time looking for the right A* pre-made assets and I tried many.

Most were hard to understand and use, plus Artillery Royale does not use anything close to a grid and basic A* assets often presume that you have some kind of grid, so it was like trying to fit circles into squares.

Anyway, at some point I decided to learn about that A* algorithm to be able to understand a better those assets.

I thought it was only going to be for my developer culture because it would have been too hard for me to implement from scratch, but I realized it was really easy.

I read a bunch of blog posts and I decided to give it a go, using my own graph data.
And guess what? It worked like a charm.

The hard part was to find navigable segment on the map, here you can see the debug with pink segments that represent walkable path and blue segments that represent possible jumps.

Those are the resource I learned from:

To be honest, if you read this you will be able to get somewhere.

For me the hard part was not the A* algorithm but building a graph that represent the game. A* (in the examples I found) is often used for grid based game, but it can be used for any graph.

Now I have a working A* path finding for my AI and I’m really proud (except that I lose several days trying to figure out assets from other instead of trying to understand A*).

Lesson learn, it’s quite often better to dive a little deeper than the asset store and look at what is behind the scene. 

Note, it’s the second time I felt in this trap, when building the destructible map I started with an asset and in the end switched to my own code.