Applying a specific pose rotation with custom anim node

Hello everyone, I have a question about how to rotate bones using Anim BP and custom Anim node :slightly_smiling_face:
My goal is to have a character finger do a specific pose when a UI button is pressed.

I’ve tried working in the order below… but my fingers don’t perfectly represent a specific pose.

  1. Accessing the skeletal mesh while playing an animation in which the character builds a specific finger pose (for example, finger heart pose) and securing the rotation of the finger bones as an RTS component

  2. Pressing a UI button that applies a specific finger pose while another animation is playing

  3. In the custom Anim node, The rotation obtained in step 1 was applied to the finger bones so that the character would represent a specific finger pose.

    const FBoneContainer& BoneContainer = Output.Pose.GetPose().GetBoneContainer();
    const FCompactPose& Pose = Output.Pose.GetPose();

    FTransform ComponentTransform = Output.AnimInstanceProxy->GetComponentTransform();

    TArray<FBoneTransform> TempTransform;
    for (const auto& BoneIndex : Pose.ForEachBoneIndex()) //FCompactPoseBoneIndex BoneIndex
    {
        FTransform NewBoneTM = Output.Pose.GetComponentSpaceTransform(BoneIndex);

        FAnimationRuntime::ConvertCSTransformToBoneSpace(ComponentTransform, Output.Pose, NewBoneTM, BoneIndex, RotationSpace); //RotationSpace = BCS_ComponentSpace

        FBoneReference& BoneReference = BoneToModifies[BoneIndex.GetInt()];
        const FName& SkeletonBoneName = BoneReference.BoneName;

        FRotator& Rotation = *BoneList.Find(SkeletonBoneName);

        if (&Rotation != nullptr)
        {
            FString HandBoneName = SkeletonBoneName.ToString();

            if (WhichHandChecked == 0)
                NewBoneTM.SetRotation(NewBoneTM.GetRotation() * FQuat(Rotation));
            else if (WhichHandChecked == 1 && HandBoneName.Contains("_l"))
                NewBoneTM.SetRotation(FQuat(Rotation));
            else if (WhichHandChecked == 2 && HandBoneName.Contains("_r"))
                NewBoneTM.SetRotation(FQuat(Rotation));
            else if (WhichHandChecked == 3 && (HandBoneName.Contains("_l") || HandBoneName.Contains("_r")))
                NewBoneTM.SetRotation(FQuat(Rotation));
        }

        FAnimationRuntime::ConvertBoneSpaceTransformToCS(ComponentTransform, Output.Pose, NewBoneTM, BoneIndex, RotationSpace);

        //Register Bone Transform
        TempTransform.Emplace(FBoneTransform(BoneIndex, NewBoneTM));
        Output.Pose.LocalBlendCSBoneTransforms(TempTransform, Alpha);
        TempTransform.Reset();
    }

Can you tell me what is wrong with my Anim BP or custom Anim node code???
I’m experimenting hard, but I’m still wandering ;O;

I’m writing this in case there are people who have similar problems as me.
Luckily my approach worked! The reason my character’s fingers rotated in a different direction than expected was because I put yaw in place of roll when getting the rotation of the finger bones.
The above approach and logic worked fine!