Access Joints of Character in C++

I am using the ThirdPerson Template. I want in C++ to access the Joints of the Skeletal Mesh of this character.

I found this Function in SkeletalMeshComponentPhysics.cpp

FName USkeletalMeshComponent::FindConstraintBoneName( int32 ConstraintIndex )
{
   UPhysicsAsset * const PhysicsAsset = GetPhysicsAsset();
   return PhysicsAsset ? PhysicsAsset->FindConstraintBoneName(ConstraintIndex) : NAME_None;
}

I am really a total beginner in C++ and UE4, so please excuse if the question sounds dumb, but how do I implement this code in my Character.cpp. If someone could show me a short example , I would be really grateful.

Do you possibly mean skeleton bones instead? you can access their transform this way:
mesh->GetSocketTransform();

Also works for rotation, location, scale.

Sockets are different to Joints . I want to be able to change the Joints angles of the Character, in order to move the bones

There are no such things as joints. Skeletons are made of Bones.

In order to directly manipulate the location or rotation of individual bones, you need to use a UPoseableMesh, rather than a USkeletalMesh. USkeletalMesh bone transforms can only be set by applying an existing animation.

See:

  1. UPoseableMeshComponent
  2. UPoseableMeshComponent::GetBoneLocationByName
  3. UPoseableMeshComponent::GetBoneRotationByName
  4. UPoseableMeshComponent::SetBoneLocationByName
  5. UPoseableMeshComponent::SetBoneRotationByName
  6. EBoneSpaces - “EBoneSpaces” is an enum indicating if you are setting the location/rotation is WorldSpace or in the Bone’s local ComponentSpace. You set pass the proper value entering the ENumName::ValueName, e.g. “EBonesSpaces::ComponentSpace”

You may find some more help here:

“How can I rotate Bones purely in C++?”

1 Like