When I run this with two players and press, in server game, Z and C both clients display correct value for LevelVariable when I press V. However, when I press X, I only get correct value at server and not at client.
Also, when I make a C++ project with a replicated variable, it requires me to implement GetLifetimeReplicatedProps. However, it seems this method is never invoked. I am using 4.7.4-2497108+++depot+UE4-Releases+4.7 on Windows.
GameInstance is itself not replicated, and exists only on Server, so its variables won’t be replicated either. Your best place for something you’d want replicated from GameInstance would be GameState, which is replicated.
I’m sorry, I am a bit confused about " GameInstance is itself not replicated, and exists only on Server". For me clients do also have a GameInstance, however, they do not have a GameMode. Maybe I misunderstood your intention or maybe you actually only meant to say GameInstance does not replicate?
Either way, from what I understood, GameInstance is only object that persists between levels. Therefore, if I want e.g. character selection to persist from one level ( menu) to another (gameplay), this must be stored on GameInstance. This means I copy my replicated variables from e.g. PlayerState to GameInstance, before I load next level. Then after loading level, variables are copied from GameInstance back to PlayerState so they can be replicated again. Is this correct way to have replicated variables persist between levels?
I am completely new to Unreal Engine, so maybe I am making things more complex than they need to be
I’ve looked into it and spoken with networking developers, and it sounds like there isn’t a clean way to do this in a content-only (no code) project. This is a feature that will require more engine work to support, and I’ll be entering a feature request to expose more functionality to Blueprints.
For a code project, you can copy Player State to Player State through CopyProperties during seamless travel.
A hacky way to do it in a content-only project that might work is to have server (only server) save data to GameInstance, then have server copy it back out to replicated variables in Player States post-travel.
Is there any update on feature request? Having to first put all variables in GameInstance and then from there copy it to all player states with a event at post is quite annoying, especially when you have lots of variables. Would be great if there would be something that travels with a level change and is also replicated. Furthermore you can’t do that event inside gameinstance.
Here here. I’m finding it impossible to set up a network game using only blueprints. I know it’s partly my own incompetence but I’m frustrated I set variables to replicate from game mode and they just don’t replicate down to clients and I still don’t know why. I keep hearing about difference between game state and game mode and I just don’t understand any of this. All I want is to share some variables and change them and for them to be same everywhere I don’t get why its so hard