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"

Is it possible to choose order of call of rep notifies?


I have a multiplayer over network game. I have an actor which has simulated physics.

When a pawn overlaps with this actor, I want to attach the RootComponent of this actor to a socket of the pawn.

On the server, when the overlap event occurs, I disable the physics simulation and do the attachment of the actor, and set a state in the grabbed actor. This state is replicated over network. I marked this state in the actor as replicated using a function

 UPROPERTY( Transient, ReplicatedUsing=OnRep_State )
 TEnumAsByte< EBallState::Type > State;

In OnRep_State:

 void OnRep_State()
     UpdatePhysicsForState(); // Here, I disable the physics

The problem I have is that the attachment of the actor on another actor is also replicated, using the function OnRep_AttachmentReplication. And as I don't control the order in which the repnotifies are called, I end up with the OnRep_AttachmentReplication being called BEFORE the OnRep_State function, and on the client, the attachment fails because the physics simulation has not been disabled yet.

The solution I put in place is to attach the actor to the parent actor on the client in the OnRep_State:

 void OnRep_State()
     UpdatePhysicsForState(); // Here, I disable the physics

     if ( State == Grabbed )
         check( CharacterOwner != NULL );

         AttachRootComponentTo( CharacterOwner->Mesh, LOCAL_RightHandSocketName, EAttachLocation::SnapToTarget );

This works well, but it would be easier to understand if I did not have this check, by being able to control the order of the calls to the rep notifies.

Is it possible? Is there a more general solution I'm not seeing there?


Product Version: Not Selected
more ▼

asked May 10 '14 at 10:29 PM in C++ Programming

avatar image

172 22 30 35

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

1 answer: sort voted first

Unfortunately there is no control over the order that rep notifies happen across separate actors. Because of the way networking works, there's no guarantee which actor will get replicated first (it has to do with things like priority and how much room is left in the packet).

Within an actor, rep notifies generally happen in the order the replication is set up in GetLifetimeReplicatedProperties. It gets confusing with AActor * though, because sometimes those get replicated down later than expected. So as a consequence of this properties in parent classes always get replicated before properties in child classes.

Another option you have is to override OnRep_AttachmentReplication to do what you want. It's just a normal virtual function, so it's really helpful to override it, call the super, and do whatever you need to do that's specific to your subclass.

more ▼

answered May 14 '14 at 12:34 AM

avatar image

[Epic]Ben Zeigler STAFF
1.3k 30 131 75

avatar image Emidee May 14 '14 at 03:09 PM

Thanks for your answer

(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