Implement A* pathfinding

Hi there

I have a TerrainQuad with a HeightMap as a terrain in my game. It’s a RTS game like AOE.

I also have 1 minion and several obstacles that I want him to avoid those obstacles.

I’ve been thinking on A* algorithm. Was thinkin on using a square grid to simplify at now.

How can I divide my TerrainQuad in squares? How can I say that my minion is in square X, and obstacle is in square Y and I want him to move to Square Z?

Thanks for the help

I suggest you to research about “Navigation Mesh” instead of using a square grid. Look here.

1 Like

And as for your question, your grid is simply coordinates. Don’t make the mistake of having a huge array[x][y], instead make a smart class that has a getTile(x,y) method and only stores data where its actually needed.

2 Likes