Hi,
I am playing around with custom AnimNode. I am not using SkeletalControlBase, just the regular AnimNodeBase to keep things simple. The code is also pretty simple:
void
FAnimNodeNPC::Update_AnyThread(const FAnimationUpdateContext& Context)
{
head.SetRotation(FQuat(0.3826834, 0.f, 0.f, 0.9238795));
}
FTransform
FAnimNodeNPC::setBoneTransform(const FCompactPoseBoneIndex& boneIndex, const FTransform& newTransform, FComponentSpacePoseContext& context)
{
FTransform newBoneTM;
FQuat rot = newTransform.GetRotation();
newBoneTM.SetRotation(rot);
const FTransform& boneTM = context.Pose.GetComponentSpaceTransform(boneIndex);
newBoneTM *= boneTM;
return newBoneTM;
}
void
FAnimNodeNPC::EvaluateComponentSpace_AnyThread(FComponentSpacePoseContext& Output)
{
const FBoneContainer& boneContainer = Output.AnimInstanceProxy->GetRequiredBones();
Output.ResetToRefPose();
TArray<FBoneTransform> boneTransforms;
FName boneName = "head";
auto boneIndex = getBoneIndex(boneName, boneContainer);
boneTransforms.Add(FBoneTransform(boneIndex, setBoneTransform(boneIndex, head, Output)));
Output.Pose.SafeSetCSBoneTransforms(boneTransforms);
}
As you can see it sets head rotation to 45 degrees to the right. That’s it. But, while it looks fine in the editor:
when in the game it shows 90 rotation instead of 45. Or generally, double any set rotation on the correct axis:
I am pretty sure i am missing something simple here, can anybody please shed a light on it? Oh, and it is the same SkeletalMesh in editor and in game, just with a few facial morphs when in game.
Interestingly, if instead of setting transform directly I pass in the HMD rotation, the character’s head follows the HMD perfectly, not with double angles… The reason that I even found the problem was the hands were messed up when following controllers…