Replicated Variables Not Updating When Prompted By Server
I'm still quite new to multiplayer programming but I imagine replication should be pretty simple once you get the hang of it. In this case, I seem to be struggling with a pretty basic rule. All online sources I can find seem to agree that if you want to update a variable that is relevant to all players for gameplay purposes, the variable should be set to replicated and they should be updated on a function running on the server. That will then pass the changes onto the clients.
That being the case, I am hoping someone can explain to me why this function doesn't work. I want the remaining moves and energy of this character to be changed for all clients when this event is called. The event runs on the server and the variables are set to be replicated, as you can see in the below image, yet only the values remain different for the server and the client. The server sees them update and the client sees no change at all.
I don't believe the authority node is required here seeing as the event should only run on the server, but I've included it regardless as frankly I don't know why this does not work. The only solution I can think of would be to multicast the changes but I don't see why I should have to if the replication works as intended.
For the record, the actor is set to replicate and I do have other replicating functions that work, but I think this is worth bringing up. I'm sure I could make this work, but I want to make sure I understand why this doesn't before I proceed. I want my code to be as efficient as possible and have the fullest understanding of the subject I'm working with.
I can provide additional context if needed but as I believe this is all that is needed. The function is called from the server and the debug text is displayed at the appropriate time. All that is left is to figure out why it does not do what it is supposed to.
Many thanks for anyone who can shed some light on this for me.
EDIT: I have also tried disconnecting the 'TurnMoveDistance' and 'MaxEnergy' variable, and instead typed numbers directly into the 'Set' nodes. This changed nothing, so the other variable values are not the issue.
This could be due to Ownership. If the client doesn't own the Actor it calls the RunOnServer event on then the event will be dropped. Look for yellow warning text in your log
answered May 19 '19 at 10:13 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here