0
\$\begingroup\$

I'm attempting to move the fingers of a prefab using muscles with the SetHumanPose method. However, the prefab is rotated 90 degrees on each call to SetHumanPose. The following is a sample of the code used:

m_humanPose = new HumanPose();

m_humanPoseHandler = new HumanPoseHandler(m_Animator.avatar, m_Animator.transform);
    
m_humanPoseHandler.GetHumanPose(ref m_humanPose);


m_humanPose.muscles[79] = -40f;     
m_humanPose.muscles[80] = -40f;
m_humanPose.muscles[81] = -40f;
m_humanPose.muscles[82] = -40f;

m_humanPoseHandler.SetHumanPose(ref m_humanPose);

I'm wondering if there's a way maybe to "bake in pose" via script?

\$\endgroup\$

2 Answers 2

0
\$\begingroup\$

You could try saving the current rotation and apply it again after all animations

m_humanPose = new HumanPose();
m_humanPoseHandler = new HumanPoseHandler(m_Animator.avatar, m_Animator.transform); 

m_humanPoseHandler.GetHumanPose(ref m_humanPose);

Vector3 originalPosition = m_Animator.transform.position; 
Quaternion originalRotation = m_Animator.transform.rotation; 

m_humanPose.muscles[79] = -40f;
m_humanPose.muscles[80] = -40f; 
m_humanPose.muscles[81] = -40f; 
m_humanPose.muscles[82] = -40f;

m_humanPoseHandler.SetHumanPose(ref m_humanPose);
m_Animator.transform.position = originalPosition;
m_Animator.transform.rotation = originalRotation;
\$\endgroup\$
3
  • \$\begingroup\$ Hi @CheckerT, Thanks for the reply. It's appreciated. I tried using that method as well as m_Animator.transform.localRotation but no avail. \$\endgroup\$ Commented Jul 16 at 15:51
  • \$\begingroup\$ What do you mean by "no avail."? \$\endgroup\$
    – CheckerT
    Commented Jul 16 at 18:31
  • \$\begingroup\$ Sorry for the typo. I meant "to no avail" \$\endgroup\$ Commented Jul 16 at 20:07
0
\$\begingroup\$

The prefab's rotation has to be retained in the Start() method and then after the call to SetHumanPose(), apply the following:

m_Animator.transform.rotation = originalRotation * Quaternion.Euler(0, -90, 0);
\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .