2 skeletal mesh transforms are not in sync after SetMasterPoseComponent

Hello, I have a problem where my two meshes do not sync properly when I enable physics on a master component.
When I am playing animations, two meshes are perfectly in sync - their world position and anim frames are an exact match. However, when I enable the physics and the master mesh falls down as a ragdoll, weird things happen. The master mesh falls down and adjusts on the ground correctly. The slave copies the ragdoll transforms exactly, BUT it is hanging in the air weirdly.

To give you a simple idea of what I’m doing: (comp is the master component, HitResult.Actor is the actor that has the master component.

USkeletalMeshComponent* NewSkelMeshComp = DuplicateObject<USkeletalMeshComponent>(comp, HitResult.Actor.Get());
NewSkelMeshComp->SetMasterPoseComponent(comp);
NewSkelMeshComp->RegisterComponent();
NewSkelMeshComp->Activate(true);

Help is appreciated.

Hey kudovickij,

The problem you see is that in your blueprint/code the slave skeletal mesh is not the child component of the master Skeletal component, so what happens is that when you enable phisics the childcomponent (slaveskeletal) will not update with the position of the master.

To solve this you just have to attach the slave skeletalmesh to the masterskeletal mesh as a child.

I hope this helps,
Elias

Thank you!!! This was exactly my problem.

Adding

		FAttachmentTransformRules rules(EAttachmentRule::SnapToTarget, EAttachmentRule::SnapToTarget, EAttachmentRule::SnapToTarget, false);

		NewSkelMeshComp->AttachToComponent(comp, rules);

Did the trick.