Networking - Variables across Level

NameColor doesn’t seem to be repnotify (where you set the variable there is no “SetWithRepnotify” and the function you show is called OnRepNamenColor, not OnRepNameColor). Did you make sure that you have marked NameColor to be repnotify and not replicated?

Also if you mark a variable as repnotify it will automatically create the OnRep function.

But what should the event do?

You use the player character to replicate the change from the client to the server (RunOnServer event) and then from the server to all clients (that’s the repnotify). Then all clients apply the change locally (that should happen inside the OnRep function then). So what you have above in those two images looks good, but you need to make NameColor repnotify and not just replicated.

Ok, let’s try something:

  1. Non Replicated GI_Name_Color property on game instance.
  2. Widget sets GI_Name_Color on game instance before travel.
  3. Map travel happens.
  4. In Player Character OnBeginPlay, if “Has Authority” (the server), end “Run on Owning Client” RPC called “SendNameColor”
  5. In Player Character “ClientSendNameColor” RPC, call a Server RPC “ServerSetNameColor” passing GI_Name_Color from GameInstance
  6. In Player Character “ServerSetNameColor” RPC, set replicated NameColor property on Player Character.

Yes my mistake, marked it as replicated. I changed it to repnotify and edit the created function. It still doesnt work. All instances (Clients and Server) have the same color the server picked.

Now the client can see the right color of the server, but the client cant see his color he set and the server cant see the set color of the client.

Change the name color property on Player Character to RepNotify and put the logic from 'Multicast Set Name Color" in the OnRep function.

If you could add some print text nodes to verify that all the RPCs are firing correctly.

I call the setcolor event on begin
play (player character)

Do have something like “IsLocallyControlled” check to only execute the SetColor Event on the local client? (since you want the local client to tell the server its color)

Now the client color is the default variable color on client and server side. The server seems to replicate correct.

334081-5.png

@chrudimer Do you answered already? It says you answered 14 hours ago, but there is no answer/comment.

It’s gone into moderation queue… =)

In 3 png you’re not sending the NameColorLocal through the UpdateColor RPC to the server and just using the default value on the server, so you also need to send the NameColorLocal from the client to the server and use that.

What do you mean exactly? The update color node sends the variable to the server or am I wrong? The rep notify updates the color on all clients.
So which rpc or note should I add to get it working?

In your image 3 png above you’re not sending anything through the UpdateColor RPC. If you want to send something though the RPC, then you need to add inputs to it, same as you would do for any CustomEvent.

334122-annotation-2021-03-30.jpg

You are a legend, thank you:) Its working now!

Thanks for your help:) chrudimer solved it for me.