I am new to Unreal and game dev in general and so to practice I am building a Chess game. I am trying to implement object selection so that a player can mouse-click on a chess piece and “highlight” it when selected. If a player clicks on another chess piece then the previous one gets deselected and the new one gets 'highlighted".
Currently, I am simply adjusting a dynamic material of my chess piece inside a OnSelected member function within a “ChessPiece” class. However, I am not sure how to deselect it when a new piece is selected. I have read that I should keep the game state in a GameState class, so I thought maybe I can store a ChessPiece* pointer inside a GameState class which points to the currently selected chess piece and so when a new one gets selected I can use that pointer to change it’s material back to being un-highlighted. But then I have a problem accessing my game state object from my chess piece class because my GameState class needs to include “ChessPiece.h” in order to hold a member variable of chessPiece* type, but my ChessPiece class needs to include my MyGameState.h in order to access it? So it seems to be a circular include.
It seems like a very poor design and I have no idea how to fix it. Any suggestions would help me a lot! Thanks in advance.