How to get the rotation information of the root bone

    FAnimPose Pose;
    TArray<FName> BoneNames;
    UAnimPoseExtensions::GetReferencePose(Skeleton, Pose);
    UAnimPoseExtensions::GetBoneNames(Pose, BoneNames);
    FTransform RootBoneTransform = UAnimPoseExtensions::GetBonePose(Pose, BoneNames[0], EAnimPoseSpaces::Local);
    FVector Translation;
    FRotator Rotation;
    FVector Scale;
    UKismetMathLibrary::BreakTransform(RootBoneTransform, Translation, Rotation, Scale);

I try to get root bone’s rotation information with the above code, but it has error. The rotation information it outputs is different from Skeleton’s root bone. This is my first time posting, thanks

In unreal the root bone is usually at the bottom of the characters base (between the feet). Are you thinking about the pelvis rotation maybe?

To get the bone rotation use GetSocketRotation() where as the name you pass in the bone name in this case “root”

FRotator USceneComponent::GetSocketRotation(FName SocketName) const
{
	return GetSocketTransform(SocketName, RTS_World).GetRotation().Rotator();
}

In you case it would be

// USkeletalMeshComponent * YourSkeletalMeshComponent;
YourSkeletalMeshComponent->GetSocketRotation("root");

USkeleton* Skeleton = Cast(Asset);

bool Result;
FAnimPose Pose;
TArray<FName> BoneNames;
UAnimPoseExtensions::GetReferencePose(Skeleton, Pose);
UAnimPoseExtensions::GetBoneNames(Pose, BoneNames);
FTransform RootBoneTransform = UAnimPoseExtensions::GetBonePose(Pose, BoneNames[0], EAnimPoseSpaces::Local);
FVector Translation;
FRotator Rotation;
FVector Scale;
UKismetMathLibrary::BreakTransform(RootBoneTransform, Translation, Rotation, Scale);

How do I get RootBone’s rotation information through USkeleton? Thank you

Skeleton->GetSocketRotation(“root”);

You are accessing the characters skeleton directly. You do not need to access any of the poses or other operations to get the rotation.


I can’t find this function in Class USkeleton, my unreal engine version is 5.1

I have understanded,your mean to get the rotation information of bone through the socket , I’ll try ,thanks