I’m making a chess-like game where both players see themselves as the blue team, and they see each other as red (like in most multiplayer shooters), and I’m also very new to networking.
Every game piece (actors) has a variable that’s a pointer to that piece’s current tile. Every tile (also actors) has 2 variables: the current state of the tile (empty or occupied) and a pointer to that tile’s current piece (if it has one). Each title also has a static mesh that indicates its current state: white for empty, red for “occupied by an enemy piece”, and blue for “occupied by a friendly piece.” These are the only things that change during runtime. Everything else (like each tile’s coordinates or a piece’s owning player index) stays the same from start to finish.
Right now, everything works as it should when the game begins: pieces’ tiles change colors for each player to reflect the piece occupying them:
But there’s a problem when one of the variables I talked about earlier changes. When I try to move a piece, the piece itself is updated for both clients (because it is set to replicate movement), but the tile does not change colors:
While trying to figure out why, I discovered that the piece’s and tile’s variables update for the client who changes them (“player 1”), but not for the other player. So the function that updates the tiles is called for both players, but the second player doesn’t know that the piece has moved.
I’m doing most of this code inside of the player controller class, but the important variables are being stored in each instance of the piece and tile classes, and those are the variables that aren’t updating for both players. I’m not sure if they’re being updated for the server either.
I’m very new to networking and I’ve tried everything but haven’t been able to fix this. I thought that maybe it was because the variables weren’t replicating, but when I made all of the variables replicated, nothing changed.
Any help would really be appreciated!
Edit: Another problem I’ve just discovered is that when playtesting in the viewport and de-possessing player 1, the tiles’ materials return to their previous states. I don’t know the the viewport playtesting works, but my guess is that the color of the tile is only changing for the first player.