Update Clients variable
I try to update a int variable in the player class, Im using a Dedicated Server. When a client increment the variable and replicate to the server, the server update the variable for all clients.
But dont work , I dont know when I have to update the variable to the clients and how exactly.
Some help please ?
asked Jul 09 '17 at 09:47 PM in C++ Programming
Hmm actually you increment index on client, after that you change on server. In this form replication is useless, i dont know why you want server validated int for media playing, but i have some idea.
So first, if you are sure you want change that int on server, do not change on client. If NextMedia called check you have authority or not, if not only just call ServerNextMedia (and onrep actually dont need to be called)
After this server will replicate the new value and will run your onrep function.
Second: i do not see player is marked replicated? Maybe in default characterd are marked, but do SetIsReplicated(true) for sure.
Third: if you try to achieve some kind of syncronized media playing, where more player can switch between media and all players need to be see that selected media, well thrn you doing wrong. Because int will be replicated to every player, but code will not run because in multiplayer local player have rights, other players are only simulated actors.. so if one of that simulated actor int will be replicated, he CANT change local actors (player) media!!! (Recommendation: read Cedric's network compedium ;) http://cedric-neukirchen.net/Downloads/Compendium/UE4_Network_Compendium_by_Cedric_eXi_Neukirchen.pdf)
So if you try to achieve this kind of achieve this kind of mechanism, you need to work with NetMultiCast RPC Which can be started from server and will run in every client..
In short: player change media -> server rpc to change media -> server sends netmulticast rpc to all clients to play switch new media
answered Jul 10 '17 at 07:09 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here