Following Tefel's Chess game instructions

Hi eveyone ,

I’m following the instructions of "Tefel " about making a chess game here is the link to the second part where the scripting of the mouse click on the chess pieces is shown : Unreal Engine 4 Tutorial #2 - Start Chess (part 2) - YouTube

I’m learning blueprints functionality and taking this tutorial as a course , so i decided to add some functionality to the game starting from the end point of this tutorial , for instance how to decide if it is black or white turn and how to go about setting the allowed moves for any piece , below my ways of doing it but i’m failing at it :

Note : the "Dark pieces " item variable (in the pictures 1, 2 ) this is an addition i created in construction script to hold all and only the Black chess pieces .

1- getting the last click color compare it to the next click color and gate the click to open only if last click color is Not equal to next click Color (see picture_1 ).

2- i tried also checking if the last click is black then setting the condition to bool variable then setting that to opposite for the next click by way " is Not bool " ( see picture _2).

So please i need advice on how to do it …!!.???

Thank you.
Best wishes.

There are couple of functions you need to write in order to check if it’s valid move and which players plays.

Let’s assume that you are using only one controller and single player game.
You need to have a state which turn it is -> I would introduce boolean iSWhitePlayer and change it from true/false when every move finishes.

Base on that you may allow to move white/black pieces which you simply check.
Every piece has already piece type and color.

Without highlighting possible moves it would just check if it’s valid on drag.

The easiest solution would be writing matrixes for every possible XY move.

-1, 0]
-1, 1]
[0, 1]
[0, -1]
[1, -1]
[1, 0]
[1, 1]

defining it for every piece is not a big deal
then you check if dragged field has valid index

in addition bishop, rook and queen needs to check if there is nothing in between

Hi Tefel,

Thank you for your response appreciated :), ,

to make sure i’m understanding what you are talking about -1.-1] is the -1 the same as last click : -1 which means the square outside the chess board …?? …

…and how to go about writing matrixes XY , is it via "Map " variable or 2d arrays ,…??..

I am having troubles when i make the chess board. it seems to be doubling up in most of the spaces. i followed the instructions but it did this when i got to about 4 mins 30 secs through the video following what it said to do