Variable Replication Question for multiplayer skills 4-27

Hello. im having troubles with the replication of some variables asigned to skills that you learn through a skill tree (With different classes). the variables are set to replicated and the action to do the skill is in two custom events one executed on server connected to other one that is set to multicast and then to the skills actions nodes.

When i learn a skill with the server with a different class than the client i can see in the client how the server is performing that skill perfect. but when i do it in the client the server cannot see that action. I cheked and the nodes stops where the check if the skill (variable) is 1 or more. Seems that the variable that the client sets its not replicating correctly and it gives false.

Any ideas?

Replication only happens when the Server Set the variable. The Client need to “ask” the server to set the variable using a Server RPC.

Clients can only make RunOnServer RPC’s from Actors that the Client own.

The client by default Own its PlayerController, PlayerState and Possessed Pawn/Character.
Actors that are owned by any of those classes mentioned will indirectly be owned and also be able to call Server RPC’s.

So basically just to confirm, if i want to set a variable with a client i have to do it in a RunOnServer event inside the Player state?

Also im not sure what RPC means. can you explain pls.

Thank you.

Yes, that way the Server is doing the set on request by the Client.

RPC = Remote Procedure Call which is what happens when one PC calls a function that executes on a different PC.

Thank you again and sorry but i’m still unable to do what i’m triying.

Now i created a LoadGamePC event that RunOnServer that is cheking the status of the variable on your save and then changing the value to the variable in the PlayerController. Here is a screenshot:

The way i call that event on the player controller is from the main character itself like this (that event is called on the begin play and also when you close the skill tree):

For doing the skill i check if the variable is seted in the PlayerController like this:

But now only the server is reproducing the skill in both client and server, but the client never do it not even in his own screen.
Please help, what i am doing wrong?

(Update) if i use get owning of this actor instead of get player controller when i cast to the Playercontroller then the client can reproduce the skill and the server sees it but the client cannot see the skill of the server even if in the screen of the server the skill is happening. it returns cast failed when triying to cast to the player controller in the server spawned player in the client:


Im also not sure if i should use get owning of this actor insted of get player controller when i call the LoadPC from the player blueprint. Im so confused right now.

I managed to di it using the playerstate

This is the skill with the check for the variable (working)

and after seting the variable inside the player with the savegame then i call this event in the player state:

Thank you for your help GarnerP57. Thanks to you i finally solved it.

2 Likes