Hello everyone, I have a question about how to rotate bones using Anim BP and custom Anim node
My goal is to have a character finger do a specific pose when a UI button is pressed.
I’ve tried working in the order below… but my fingers don’t perfectly represent a specific pose.
-
Accessing the skeletal mesh while playing an animation in which the character builds a specific finger pose (for example, finger heart pose) and securing the rotation of the finger bones as an RTS component
-
Pressing a UI button that applies a specific finger pose while another animation is playing
-
In the custom Anim node, The rotation obtained in step 1 was applied to the finger bones so that the character would represent a specific finger pose.
const FBoneContainer& BoneContainer = Output.Pose.GetPose().GetBoneContainer();
const FCompactPose& Pose = Output.Pose.GetPose();
FTransform ComponentTransform = Output.AnimInstanceProxy->GetComponentTransform();
TArray<FBoneTransform> TempTransform;
for (const auto& BoneIndex : Pose.ForEachBoneIndex()) //FCompactPoseBoneIndex BoneIndex
{
FTransform NewBoneTM = Output.Pose.GetComponentSpaceTransform(BoneIndex);
FAnimationRuntime::ConvertCSTransformToBoneSpace(ComponentTransform, Output.Pose, NewBoneTM, BoneIndex, RotationSpace); //RotationSpace = BCS_ComponentSpace
FBoneReference& BoneReference = BoneToModifies[BoneIndex.GetInt()];
const FName& SkeletonBoneName = BoneReference.BoneName;
FRotator& Rotation = *BoneList.Find(SkeletonBoneName);
if (&Rotation != nullptr)
{
FString HandBoneName = SkeletonBoneName.ToString();
if (WhichHandChecked == 0)
NewBoneTM.SetRotation(NewBoneTM.GetRotation() * FQuat(Rotation));
else if (WhichHandChecked == 1 && HandBoneName.Contains("_l"))
NewBoneTM.SetRotation(FQuat(Rotation));
else if (WhichHandChecked == 2 && HandBoneName.Contains("_r"))
NewBoneTM.SetRotation(FQuat(Rotation));
else if (WhichHandChecked == 3 && (HandBoneName.Contains("_l") || HandBoneName.Contains("_r")))
NewBoneTM.SetRotation(FQuat(Rotation));
}
FAnimationRuntime::ConvertBoneSpaceTransformToCS(ComponentTransform, Output.Pose, NewBoneTM, BoneIndex, RotationSpace);
//Register Bone Transform
TempTransform.Emplace(FBoneTransform(BoneIndex, NewBoneTM));
Output.Pose.LocalBlendCSBoneTransforms(TempTransform, Alpha);
TempTransform.Reset();
}
Can you tell me what is wrong with my Anim BP or custom Anim node code???
I’m experimenting hard, but I’m still wandering ;O;