I had an issue with skeletal meshes where the root bone is not the base where physics body root is causing were grip rotations. I added logic to correctly find the root physics in the skeletal mesh and resolves issue. Don’t know if any other user has hit issue but I did.
// I actually don't need any of code anymore or the HandleInfo->RootBoneRotation
// However I would have to expect people to pass in the bone transform without it.
// For now I am keeping it to keep it backwards compatible as it will adjust for root bone rotation automatically then
USkeletalMeshComponent * skele = Cast<USkeletalMeshComponent>(root);
if (skele && skele->GetNumBones() > 0)
{
// RJM - Was RootBoneRotation = FTransform(skele->GetBoneTransform(0, FTransform::Identity));
// RJM - Not all skeletal meshes have root bone as 0 for physics
// need to know which one it is.
int rootBone = 0;
FBodyInstance* rBoneInstance = nullptr;
for (int bone = 0; bone < skele->GetNumBones(); bone++) {
rBoneInstance = skele->GetBodyInstance(skele->GetBoneName(bone));
if (rBoneInstance != nullptr && rBoneInstance->IsValidBodyInstance()) {
rootBone = bone;
break;
}
}
RootBoneRotation = FTransform(skele->GetBoneTransform(rootBone, FTransform::Identity));
HandleInfo->RootBoneRotation = RootBoneRotation;
}