How do i do tactical gridbased movement with movement points?

Hi people.

I’m making a tactical, boardgame-esk game where the player controls blocks of soldiers. Like the tabletop version of Warhammer fantasy, but with a few ideas from x-com mixed in.

What I’m trying to do is make a movement system where the player selects the unit he wants to move, and presses the left mouse button where he wants to move it. The player will see a “movement shadow” of where he can move and as he moves the mouse it displays how many movement points it will cost him to move there. A bit like what you get in the Heroes of might and magic series.
The unit should only be able to move on its local z axis.

I think this has to be grid based, and if so is it possible to make 4 squares count for 1 movement point?
Or would it be easier to just multiply the movement points by 4?

I have the part about selecting the unit and moving it to where I click, but I can’t seem to restrict movement only to its local z, and have no idea how to do the “movement shadow” or movement points.

I hope that was somewhat understandable :stuck_out_tongue:

Can anyone point me in the right direction for solving this, or link me to a tutorial(s) for this. Using C# btw.

Thx in advance

Streg.

You could use a pathfinding algorithm based on a grid. The algorithm would return the available spaces a unit could move. You could assign each tile a “cost” to move there meaning if a space had a cost of 0, then it’s impassable.

Or just write your own custom method where you calculate the movement points from the current unit position to every available position the unit can reach. Again you’d want to use a cost just in case you want to block certain positions.

http://answers.unity3d.com/questions/820030/path-finding-algorithm-for-2d-game.html