C64debug
(C64debug)
1
All,
I’m trying to retrieve the local transform of a bone from a skeleton, like you can get from the editor:

I need to do this for a mesh that is not positioned in the world.
I am able to list all of the bones + sockets from a skeletal mesh like this:
TArray<FName> BoneNames = SkeletalMeshComponent->GetAllSocketNames();
for (FName Bone : BoneNames)
{
UE_LOG(MyLog, Error, TEXT("%d - bone: %s"), UniqueID, *Bone.ToString());
}
I can see printed all the bones in the output. However, I cannot retrieve the bone socket:
USkeletalMeshSocket* BoneSocket = (USkeletalMeshSocket*)SkeletalMeshComponent->GetSocketByName("hand_l");
USkeletalMeshSocket* BoneSocket = SkeletalMeshComponent->SkeletalMesh->FindSocket("hand_l");
USkeletalMeshSocket* BoneSocket = SkeletalMeshComponent->SkeletalMesh->Skeleton->FindSocket("hand_l");
All of these return a nullptr BoneSocket. I was hoping then to just do a BoneSocket->GetSocketLocalTransform()
to get the information I want.
BTW the socket is reported to exist:
// this returns true
SkeletalMeshComponent->DoesSocketExist("hand_l")
Can some kind soul tell me what I am missing?
Thank you,
r.
1 Like
C64debug
(C64debug)
2
I’ve also tried:
TArray<USkeletalMeshSocket*> Sockets = SkeletalMeshComponent->SkeletalMesh->Skeleton->Sockets;
Since these are supposed to contain the relative location information:
https://docs.unrealengine.com/4.26/en-US/API/Runtime/Engine/Engine/USkeletalMeshSocket/
However, no success as Sockets
is an empty array.
1 Like
C64debug
(C64debug)
3
I’ve also tried:
int BoneIndex = SkeletalMeshComponent->GetBoneIndex("hand_l");
USkinnedMeshComponent* SkinnedMesh = (USkinnedMeshComponent*)SkeletalMeshComponent->SkeletalMesh;
FVector LocPose = SkinnedMesh->GetRefPosePosition(BoneIndex);
UE_LOG(LogSimpleProceduralWalk, Error, TEXT("%d - %s: LocPose %s"), UniqueID, *Leg.ParentBone.BoneName.ToString(), *LocPose.ToString());
All of these return a 0, 0, 0
FVector.
1 Like
C64debug
(C64debug)
4
For anyone having similar issues and happens to bump in this thread, this is what finally got me the pose data:
int32 BoneIndex = SkeletalMeshComponent->GetBoneIndex("hand_l");
FAnimationRuntime::GetComponentSpaceTransformRefPose(RefSkeleton->GetReferenceSkeleton(), BoneIndex);
Where RefSkeleton
is a USkeleton
, data is in Component Space.
1 Like
aliemci
(aliemci)
5
I think you can use
const FTransform handLTransform = GetMesh()->GetSocketTransform(TEXT("hand_l"), ERelativeTransformSpace::RTS_ParentBoneSpace);
3 Likes
C64debug
(C64debug)
6
Not unless the mesh is in the world, which is my whole point
This will return a 0 vector.