I found a (potential) bug with attachment replication.
Here’s what I’m doing:
-
I attach one SceneComponent to another on the server for PlayerA
-
On PlayerB’s client this got replicated via OnRep_AttachParent for remote version of PlayerA and everything seems fine
-
Then I detach this component for PlayerA on the server
Here’s what’s happening next:
-
On PlayerB’s client new AttachParent (which is NULL now hence detach) gets replicated for remote version of PlayerA
-
Inside USceneComponent::PreNetReceive() OldAttachParent gets stored with previous non-zero value of AttachParent
-
Then AttachParent gets initialized to NULL (new value)
-
Then in USceneComponent::PostRepNotifies() it tries to attach to NULL and nothing happens (there is no auto detach if trying to attach to NULL) but because of Swap operation the AttachParent is again pointing to the old parent
-
Finally the component remains attached to the old parent (on PlayerB’s client for the remote version of PlayerA)
Is this by any chance an intended behavior?
How should I handle detach for remote clients?