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"

Are all replicated variables updated from the server before calling RepNotifies?

Hello, i want to know if the replicated variables updated from the server are all updated first and only after that will it start calling the repnotifies? Or does he call the repnotify immediately after updating the replicated variable? Thank you

Product Version: Not Selected
more ▼

asked Oct 08 '14 at 11:38 PM in C++ Programming

avatar image

6k 162 129 305

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

1 answer: sort voted first

Hi there,

The properties are updated first, then the rep notify is called. So by the time you get the rep notify, the property will be up to date.

If you want the old value, you can add the value as a parameter to the rep notify, and it will pass the old value in that case.

more ▼

answered Oct 09 '14 at 03:58 PM

avatar image xlar8or Oct 09 '14 at 04:04 PM

So if i have 3 properties that are going to be updated from the server he does something like this?

 foreach(Variable to be Updated)
       Variable = ValueFromServer;
 foreach(Variable to be Updated)

Because i have a character actor where i call EquipWeapon (which sets bIsEquipping to true and sets Weapon to the new weapon) PostInitializeComponents on the server (ROLE_Authority). The repnotify for bIsEquipping is called on the client but Weapon is still null so it crashes when i call EquipWeapon.

avatar image [Epic] John Pollard STAFF Oct 09 '14 at 04:06 PM

Ahh, this is because the weapon actor hasn't come through yet, so it is NULL. This is an unfortunate side effect of how replication works in UE4, but there is not much we can do here (we don't know that those two properties are dependent on each other).

The best way to handle this is to probably use a rep notify for the actual weapon object, and then react to that coming in instead.

avatar image xlar8or Oct 09 '14 at 04:12 PM

But apparentely this only happens when i call EquipWeapon on PostInitializeComponents, if i call it during the game it will work. The only reason i use the boolean to repnotify is because actually i have 2 weapons (weapon right and left) to possibly dual wield and i want to do a different animation for equipping single and double, so with 2 repnotifies for both weapons might not always have the correct value for the other weapon to select the right animation. Previously i did the equip first through the server and then did a Client multicast function to replicate to all clients, but i shouldn't abuse Client functions right?

avatar image [Epic] John Pollard STAFF Oct 09 '14 at 04:15 PM

It probably works the second time since the weapon actor was already on the client, or in some cases it's a timing thing.

The main take away is you can't rely on when exactly a actor reference will arrive, and have to assume they will arrive out of order with respect to other actor references, and code around it.

You can add a rep notify to both weapons, and then don't react until both are not NULL for example.

avatar image xlar8or Oct 09 '14 at 04:21 PM

Ok, so basically with repnotify i can't trust that the variable dependencies (even if they were both changed on the same function) will be there when it triggers the OnRep (a bool is much faster to transmit than a Weapon, so that's probably why it reaches first). I just assumed that the server at the end of the tick packages all the variables that are different from the client and sent them all in one take. I guess that's not the case and they come as they go in different client ticks. I will try to do what you suggest then. Worst case i use Client functions, but that means that the action will have to start on the server first instead of the originating client, which is always bad for responsiveness if your net is not good. Thank you :)

avatar image [Epic] John Pollard STAFF Oct 09 '14 at 04:45 PM

That's correct for object/actor references. For int's, floats, and other non object properties, they are guaranteed to arrive together if they were changed together.

avatar image muchcharles Feb 21 '19 at 07:36 PM

Is this true if there are enough properties to make the update go beyond the bunch size boundary? At least for initial replication I didn't think this was the case.

avatar image xlar8or Oct 09 '14 at 05:14 PM

That type of information would be very helpful to be documented, because it's those little details that make you lose so many hours :P Thank you :)

avatar image [Epic] John Pollard STAFF Oct 09 '14 at 05:15 PM

Np, I've make a note to document these things better!

avatar image xlar8or Oct 09 '14 at 05:21 PM

I think one of the most complex things in UE 4 is replication, i've been working for weeks full time, trying to understand the concepts and making everything work with repnotifies and client functions and how everything ties together, and i feel that there is still very little in depth documentation. I've been reading the UE 3 documentation and it helped, but i still found myself with a lot of questions, and i'm sure i'm not the only one :)

(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