Found a bug with AttachParent replication

I found a (potential) bug with attachment replication.
Here’s what I’m doing:

  1. I attach one SceneComponent to another on the server for PlayerA

  2. On PlayerB’s client this got replicated via OnRep_AttachParent for remote version of PlayerA and everything seems fine

  3. Then I detach this component for PlayerA on the server

Here’s what’s happening next:

  1. On PlayerB’s client new AttachParent (which is NULL now hence detach) gets replicated for remote version of PlayerA

  2. Inside USceneComponent::PreNetReceive() OldAttachParent gets stored with previous non-zero value of AttachParent

  3. Then AttachParent gets initialized to NULL (new value)

  4. 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

  5. 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?

Hello,

We’ve recently made a switch to a new bug reporting method using a more structured form. Please visit the link below for more details and report the issue using the new Bug Submission Form. Feel free to continue to use this thread for community discussion around the issue.

https://epicsupport.force.com/unrealengine/s/

Thanks

I’ve noticed this too. I’m trying to detach a capsule, detach the mesh, then set the mesh as the root component for the actor, so that mesh replication drives the actor. However, the capsule goes back to being the mesh’s parent and root component and it all happens starting from this PostRepNotifies. I cannot figure why it just sets the old parent as the new parent with that Swap/Exchange operation.