Getting tiles relative to in a Grid of tiles

Hi,
thank you for your support.

i’m facing a situation in blueprint where i have a grid of tiles and i created an array of tiles indexed with integers from 0 to 120 so i have 120 tile ,

Now what i want is to make the tiles (that are allowed for my static actor to move to ) glow , so how can i start thinking about the logic to get the indexes of the tiles that sits straightforward relative to a certain tile index ??, or in any direction i want ,basically what i’m talking about is like a chess board and setting the allowed moves for a certain piece like Knight .

what i want resembles exactly the default chess game in win 7 where they are setting the tiles allowed to glow picture below…

So, if your board is h*w, and you are indexing them as

1 2 3 4 5 …w

w+1 w+2 w+3…2w

h*(w-1)…h*w

To find the grid one above, you add -w to the index.

To find the grid one below, add w.

To find the left/right, add -1/1.

To check if you are in the left or right edges of your grid, check if your index%w == 1 or w-1.

To check if you are in the top or bottom edges, check if your index is less than w (top edge) or more than h*(w-1) (bottom edge).

Its a lot simpler in C++ with 2d arrays, if you know how to use C++ i recommend you use it instead. If the math above is too much work for you, or your game has a lot of complex rules, you can check out this solution instead:

You basically create a struct called row, that has an array with the size of your w, and your board is an array of rows.

Thank you for your response, appriciated ,
I understand your idea ,but not much how to apply it to the situation , let’s say i have a real life-like chess board , to represent it in UE4 :

1- along the Y axis will be Columns labeled by the letters a,b,c,d,e,f,g,h .

2- along the X axis will have Rows labeled by the numbers 1,2,3,4,5,6,7,8

Isn’t that similar to data table in ue4 …,???

just tell me if it’s right or it’s a disaster , so My plan is :

1- To create the struct called Columns concists of individual variables of type String or Name called a,b,c,d,e,f,g,h ( they are saying that names are faster to process i don’t know)

2- To create a Data-table called “CrossSection” consisting of the struct called “Columns”

3- and the columns of the Data-table will be automatically the key names of the individual variables type String or Name ( a,b,c…,h) created inside the struct “Culumns”

4- then create rows named 1,2,3…8 which are the rows of the data table and set the variables values in the cross sections of the table to be respectively a1,b2,c3…f8,g7,h8 = those are variables type Name or String which i set in the rows (1,2,3…8) of the Data-table …

5- pull these values when needed in the graph with the nodeS Data-table or create an array from them if i wish to represent each tile of the whole board .