[question] Setting a units movement distance without using a grid map in a turn based strategy game.

Do i have to use a grid map or can it be done without one?

I have been learning from tutorials and have become stuck when it comes to grid maps there are no tutorials out there on how to build a hex grid map. there are a few examples but they don’t really go into detail on the process involved in making them.

You can do distance without a grid map quite easily. Just track how far the pawn has moved from it’s original location and do a prediction to show their maximum distance

I would recommend a grid, even if only for the AI.

Otherwise, you take the vector of the character and measure the distance to the target vector, and if under your specified limit you allow it to happen.

There are a few developers on these forums who have made attempts at making gridless TBS games. Ryukra made a thread of it here a while ago, though I think he has since abandoned the project. You might want want to send him a PM if you want to make something similar. Stormrage256 was also working on a semi-gridless tbs system before switching to full grid based. Here’s a video of his older WIP game.

I prefer working with grids myself, though, and creating a hexagonal grid in UE4 is pretty easy. All you need to do is to create an array that holds the locations of all the tiles of the grid. You can make this easily by running a for-loop that adds vectors to a vector array. You’ll need to input two integers for the width and length of the grid, and then you add a vector with an X-value equal to the loop index modulated by the width of the grid and add a Y-value equal to the index divided by the width of the grid. You’d want to multiply both of these values by the size of each grid cell. Like so:


For hexagonal grids the process is pretty similar, but you have to offset every other grid row by half the size of your grid cells. Also, the Y distance between rows should be 0.75 times the distance between columns (provided your hex grid is not flat-topped, in which case you replace columns and rows in the last sentence). You’ll end up with something like this:


Now do a forloop on your new vector array and add a hexagonal static mesh (preferably instanced static meshes if you use a large grid) to every output vector and you should end up with something like this:


For distance calculations you could do what Zeustiak is suggesting.

For more info on hexagonal grids I would look at Amit’s excellent website here.