Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Replicated Variables Not Updating When Prompted By Server

Hi there,

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.

alt text

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.

Product Version: UE 4.22
more ▼

asked May 19 '19 at 01:15 AM in Blueprint Scripting

avatar image

33 1 4

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

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 No owning connection for actor which indicates that this is exactly what is happening. You solve this by letting the client own the actor by calling SetOwner on the server. The outermost owner has to be a PlayerController. Example could be Weapon owned by Character owned by PlayerController.

more ▼

answered May 19 '19 at 10:13 AM

avatar image

936 3 4 8

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question