Turn based strategy : preview path

Hello,
I am coding a turn based strategy game where players have several units.

When a player click on an unit, I would like to preview all the tiles where this unit can move.

I use Pathfinding behaviour but I have only moveto function. I would like to use a function with a destination point in parameter that returns a list of waypoints or returns if a path has been found.
With the result I would display a highlight tile explaining that the move is possible in this tile.

How do you do that ?

Regards

in a similar game I solved this: an invisible “sprite” starts from the Player’s position and makes its path in advance until it reaches the destination, if this “sprite” does not find any obstacles, then it returns the value "True “and therefore the Player can make that move, if instead the invisible” Sprite “finds obstacles, then it returns the value” False ", so the Player will not be able to make that path.

Attention that the Pathfinding is calculated by the PC and not by you, so it cannot be used with the example made by me. In that case the path to be carried out must already be programmed by you, which must be the same that both the invisible Sprite (in advance) and then the Player (possibly) will do

1 Like

Ok thanks. But I would like to use the Pathfinding. Behaviour.
I thought to create several fake objects and move them to destinations. If path has been found then I create a highlight tile.
But I do not find how to do that with code…

Any helps ?

How did you setup your board?
If every tile is a sprite object I can share my method

If your game is not grid based, look up the tank pathfinding example and do, as Salvatore suggested and let a hidden object find the path first.

Here is my Spirit Battles Pathfinding System
It has many useful features, including different terrain bonus/malus for the pathfinder.

Yes, every tile is a sprite object