Update skeleton rest pose of one instance of skeletal mesh

Hi all,

I’m currently trying to update the rest pose of the skeleton of my character to make it match some shape change.

To do this, I’m using the following code where MeshCmp is a USkeletalMeshComponenent and MyOffsets and MyBoneNames are my inputs.

TArray<FVector> MyOffsets;
TArray<FName> MyBoneNames;

FReferenceSkeleton NewSkeletonRef;
FReferenceSkeleton RefSkeleton = MeshCmp->SkeletalMesh->Skeleton->GetReferenceSkeleton();
TArray<FMeshBoneInfo> SkelRefBonesInfo = RefSkeleton.GetRefBoneInfo();
FReferenceSkeletonModifier SkeletonModifier(NewSkeletonRef, MeshCmp->SkeletalMesh->Skeleton);
TArray<FTransform> BonesRestBonesTr = RefSkeleton.GetRefBonePose();
for (int j = 0; j < MyOffsets.Num(); j++)
    FTransform boneTransform;
    int32 SkeletonIndex = RefSkeleton.FindBoneIndex(MyBoneNames[j]);

    if (SkeletonIndex >= 0)
        // get rest bone for this bone
        FTransform boneRestTr = BonesRestBonesTr[SkeletonIndex];
        boneTransform.SetLocation(boneRestTr.GetLocation() + (MyOffsets[j] * Value));
        // update pose transform
        FMeshBoneInfo boneInfo;
        boneInfo.ExportName = SkelRefBonesInfo[SkeletonIndex].ExportName;
        boneInfo.Name = SkelRefBonesInfo[SkeletonIndex].Name;
        boneInfo.ParentIndex = SkelRefBonesInfo[SkeletonIndex].ParentIndex;
        SkeletonModifier.Add(boneInfo, boneTransform);

This kind of works since my skeleton rest pose is indeed modified as expected by it is modified for all characters using the same skeletal mesh.
Since most of my characters use the same base skeletal mesh, it’s not what I’m after.
So my question is : how could I modify the rest pose of the skeleton only for the instance of the given skeletal mesh component?

Thanks for your help.

So I answer my own question in case someone ever stumbles on this question and hasn’t figured out yet how to do.

It’s so simple that I don’t even understand how I missed it before: in fact, there is a function all set up for specifically doing that in the USkeletalMeshComponent class : SetRefPoseOverride which takes an array of FTransform as input and there you go…

You’re my lifesaver!! many thanks!

I have done it according to you, but it still has no effect.

Hi, I am doing this (SetRefPoseOverride) in 4.22 and the result is a stretched out and incorrectly angled pose on the target which has an identical skeletal mesh?

Could it be broken in this version of the engine?

How did you solved the stretching? SetRefPoseOverride and even your original solution up, cause mesh artefacts.

I even tested it in Unreal 4.24 and it was still stretched, so I just made a new animgraph with a single anim node that simply set each bone to what I had recorded for a given pose and that works great.

It is sad that SetRefPoseOverride does not work and no one from Epic responded to my question: Calling SkeletalMeshComponent SetRefPoseOverride on identical instance of a skeletal mesh produces stretched and incorrect bind pose on target - Character & Animation - Epic Developer Community Forums