I created a variable called by User Holding, and created a custom event to run on server side. This variable is setted as replicated method, to share with clients (As you can see in attached images). When I print that, it’s treated like a local variable.
How can I solve that?
But where do you call the event?
I did it again in simple way, as you can see in attached images. But still not working as expected. It’s being treated like local variable, different values on server and all clients. I think it should be equal for all users.
Running, I pressed F button on server side after I pressed E to see what was added in variable (100 is default to add in variable, hard value/code, as you can see in images).
The result was: “Server: 100”. (Ok, great, it’s working fine)
I switch to another screen, client side, and press E to see what is the variable value, and it’s printing: “Client: 0”. (It should appear 100, right? Because it is what I need share between clients/servers).
I can be wrong, if I’m wrong how can I do share equal to all ?
What I saw is different variable for each user on server, but I need it be shared variable, like a unique variable for all.
Following the tutorials a variable with replication will REPLICATE with all clients if that executed on server side. You can see that: Unreal Engine 4 Good to Know - Variable Replication - YouTube
What he did works normally, is almost the same what I did.
He executed it on server function and the variable is replicated mode.
I think that it’s spawned because I use PlayerStart.
The reason you are getting 0 on the client is because each client has its own variable and if you never set the variable to 100 for the client it will stay like that. I think you are confused on how the server client model works. I think you are assuming that putting a variable in the character blueprint will make it so every character shares that same variable, which is not true. Every character you create is independent and will have its own values.
If you want every player to know about a value, maybe a good place to put this value would be on the game mode (which only exists server side), so every client character could call a run on server event, so their sever counterpart can get the game mode and get the value that you want and then put that on a replicated variable.
Or maybe I’m not understanding what you really want.
The actor is spawned on server or placed in level and is set to replicate?
If you are trying to send RPCS from the client, make sure that you set the actor ownership correctly (or have it possessed) in order to have a valid owning connection to the server, otherwise you will need to send an RPC through the player controller that the client owns to the server carrying a reference to the actor you want to call stuff on when it gets to the serverside