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
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:
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?
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.
answered May 14 '14 at 12:34 AM
[Epic]Ben Zeigler STAFF
Follow this question
Once you sign in you will be able to subscribe for any updates here