Hello,
I’ve been working on a RTS game for months. So far, I am glad of what I’ve done, but I recently became skeptical about the way I implemented things. I have an option in the game mode where you can choose between coop (all the players share the same buildings and resources) and 1v1.
To do that, the resources of all the team are stored into the GameMode (Team1Resources, Team2Resources, ect).
Since only the server can access / modify the GM, the players have only one TeamResources in their PlayerState.
Everytime Team1Resources is changed in the GM, I do the following in the GameMode:
I take all the PlayerControllers of the game, check if they are in the team1. If they are, I get their PlayerState and I call a function in the PlayerState (replicates: run on owning client), passing it the proper parameters / values to update the TeamResources in the PlayerState.
Is it a proper way to do so? I’m skeptical because I feel the GM should not be able to call the PlayerState function on owning client if that PlayerState is not on the server.
Still, I manage to get all my UI resources syncrhonized for all the players. Mostly.