I want to get the relative position of a bone from the origin on a skeletal asset using Blueprint. The position before transformation with Anim BP.
Is this possible?
I don’t think it’s possible to do that within blueprints, however, there’s how you can do that in C++
FTransform GetRefBoneComponentSpaceTransform(const FReferenceSkeleton& RefSkeleton, const FName& Bone)
{
const int32 BoneIndex = RefSkeleton.FindBoneIndex(Bone);
const TArray<FTransform>& RefPose = RefSkeleton.GetRefBonePose();
FTransform Result = RefPose[BoneIndex];
int32 ParentIndex = RefSkeleton.GetParentIndex(BoneIndex);
while (ParentIndex != INDEX_NONE)
{
Result = Result * RefPose[ParentIndex];
ParentIndex = RefSkeleton.GetParentIndex(ParentIndex);
}
return Result;
}