Reading Variable From Gamemode As a Client
A project of mine uses a Gamemode class to base logic where enemies spawn in waves, which has an integer variable called CurrentWave.
All players have a HUD that displays the current wave, however, I've had difficulties replicating the integer variable from the Gamemode to the client. From what I've read, Gamemodes only exist on the server, thus calling RPCS or replicating variables wouldn't change anything apart from itself.
I've tried using a for-loop on the Gamemode per tick to loop through all existing PlayerControllers, then setting another replicated integer variable on that, so it would (hopefully) replicate to the client and could be read by the HUD, but it only just works on the server and not the client.
I am ears open to anyone who can correct me since my understanding on networking is fragile.
asked Jan 31 '19 at 08:01 AM in C++ Programming
I believe the easiest (and the clearest) solution would be to store
answered Jan 31 '19 at 09:36 AM
I've actually used the Gamestate before trying out the PlayerController, until I decided to give it another go, then realising that the variable in GameState never replicated. I forgot to mention that the int CurrentWave was in a replicated struct, in which I also forgot to add UPROPERTY() on top of each variable. Now it works fine :)
answered Jan 31 '19 at 11:56 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here