- Home /
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?
Answer by adept22 · May 07, 2012 at 02:24 PM
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.
$$anonymous$$aybe turnTime*baseSpeed*yourScaleFactor?
Answer by Berenger · May 04, 2012 at 03:12 PM
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.
Answer by captaincrunch80 · May 08, 2012 at 11:27 PM
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.
Thanks for that book quite interesting. Yes i have pretty much gotten rid of the notion of use A and going to write my own pathfinding as i have now implemented a grid square based system which will make pathfinding easier.
Your answer
![](https://koobas.hobune.stream/wayback/20220613071100im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Hexagon A* Pathfinding - limiting path length 0 Answers
How can I get my pathfinding algorithm to know that it cant go through certain sides of tiles 1 Answer
3D Grid Based Movement (X-Com 2012 etc) – How to implement vertical movement? 0 Answers
Astar Pathfinding ai moves more nodes than it should 0 Answers
Board-game pathfinding system (Similar to Mario Party style) 1 Answer