Now, we need to add some logic to this project. In order to achieve the tic-tac-toe mechanics and develop speaking, we need to do the following:
Handle a turn-based mechanic
Know when someone wins
Show the state of the game
Store a winning counter for each player
Handle the restart
Open PuzzleBlock and PuzzleBlockGrid Blueprints as we are going to frequently switch between them.
First of all, we need to know which player has to move: the X or the O. In order to achieve this, also since this is a two-player game, we can use a simple Boolean variable that is stored on the PuzzleBlock grid class and grant it accessibility through the single block class.
Go to the grid class and add a new variable, call it IsX
, and give its type as Boolean. From now, for our convenience, player 1 is always X and player 2 is O. Add Tooltip from the Details panel such as is player 1
and leave the other parameters as default:

Now, in order to check which player is playing from...