# A* Pathfinding in a turn based game

Hi i am currently building a very simple 3d turn based game and I am having some issues with doing pathfinding.

Currently i am using Arongranberg.com A* Pathfinding Project, I have path finding working perfectly fine in a real time scenario for my game objects so thats not the problem.

The problem i have is im now implementing the “turns”

Basically i plan on splitting the turns up into a number of seconds ie 15 seconds per turn. The player object will only be able to move a certain distance based on its speed. so if it can move 1metre a second in a turn it can move 15metres.

I’m a bit stuck on ideas on how to handle path-finding in this scenario. I would want it to that when i am in the movement phase i will use the A* library to calculate a path based on the mouse cursor position highlight in green how far that object will be able to move in the “turn” and show red for any part of the path that is out of that objects range.

Hopefully somebody could possibly give me some ideas on how to handle this?

I guess you want the player to prepare its action without the counter going down and then he execute. It probably woudn’t be that hard to trace the path, calculated with the mouse, with lineRenderer, green if the total length < maxDist and red otherwise. But if you want to cover the entire ground with red or green based on weither it can be reached, that’s sounds complicated, especially if your games isn’t based on tiles.

hi yes not really worried about covering ground thats not the issue ive already got that covered. its trying to come up with a formula that will calculate how far a unit can move based on the turn time, and the base speed of the unit.

Simple! Calculate a path for every changed mouse or cam position. Calculate it’s length and give the path red or green color to indicate if it is possible to move there this round.

Is the game based on squares? Because maybe you can implement something smaller and faster performing than A*. (I do not know your scenario, maybe A* is the right choice allready.) - I recommend the book Artificial Intelligence for Games from Millington&Fudge.

https://www.udemy.com/course/turn-based-strategy-game-development/
turn based game dev tutorial. Like heroes of Might and Magic