I am going to check and rebuild this video. How to replicate variables.
It is really for dummies, can’t get simpler :-).
Because I want to understand Dedicated Server, I am only going to run from the client
My final conclusion is that the video above is not correct. Only the Server and the Client connected by the character can replicate variables!
Official documentation https://docs.unrealengine.com/en-US/Resources/ContentExamples/Networking/index.html
Second video
Step 0 Build the blueprints from the first video
I used key’s K and L
Step 1 No Replication, variable is set on client
I hit K and L on client 1. So in Client 2 there is nothing happening. And the integer is not changed on the server
Step 2 Replication is enabled, variable is set on client
Nothing changes because replication on a client does not do anything
Step 3 Replication is enabled, variable is set on server
Variable changes on Client 1 and Server, but not on Client 2. I have to hit K on client 2 to get it changed on client 2. So in this setup the variable is not changed on the other client. This because only Server and client 1 are connected through the character, when I hit the key on Client 1
When asked I asked for a reaction in Unreal Slackers, I got the following answers:
Replicated variables only update when set on server. Setting them locally will change them until the next replication consideration, where they’ll get corrected back to server value
You have two instances of that character. When you press l, you are checking that characters instance.
The variable is not global but is on each instance of thirdperson character. So it changes only for that character pawn, but it does so on both server and client. The thing is, each client is controlling a different thirdpersoncharacter with its own instance of that variable
All three views (server, client1, client2) see 2 characters. Your local input only goes to the locally controlled character.
If you want a variable that is not specific to each instance of the actor but rather is shared across the whole game session for everyone then it is better to put it in a central location like the Game State
Second video
Step 4
So it turns out that you can use a “Run on owning client” event together with a “run on server” event!
Video discussing the result.
So actually I am not 100% happy with the result. I want the server to know the name of the client and the health should be printed at the client.
Step 5 Make save namefunction on Interface and on Gameinstance
Step 6 Change Blueprint Character
Result step 5 and 6