protected void SetModelArmsInTpose()
{
Vector3 vTposeLeftDir = transform.TransformDirection(Vector3.left);
Vector3 vTposeRightDir = transform.TransformDirection(Vector3.right);
Animator animator = GetComponent<Animator>();
Transform transLeftUarm = animator.GetBoneTransform(HumanBodyBones.LeftUpperArm);
Transform transLeftLarm = animator.GetBoneTransform(HumanBodyBones.LeftLowerArm);
Transform transLeftHand = animator.GetBoneTransform(HumanBodyBones.LeftHand);
if (transLeftUarm != null && transLeftLarm != null)
{
Vector3 vUarmLeftDir = transLeftLarm.position - transLeftUarm.position;
float fUarmLeftAngle = Vector3.Angle(vUarmLeftDir, vTposeLeftDir);
if (Mathf.Abs(fUarmLeftAngle) >= 5f)
{
Quaternion vFixRotation = Quaternion.FromToRotation(vUarmLeftDir, vTposeLeftDir);
transLeftUarm.rotation = vFixRotation * transLeftUarm.rotation;
}
if (transLeftHand != null)
{
Vector3 vLarmLeftDir = transLeftHand.position - transLeftLarm.position;
float fLarmLeftAngle = Vector3.Angle(vLarmLeftDir, vTposeLeftDir);
if (Mathf.Abs(fLarmLeftAngle) >= 5f)
{
Quaternion vFixRotation = Quaternion.FromToRotation(vLarmLeftDir, vTposeLeftDir);
transLeftLarm.rotation = vFixRotation * transLeftLarm.rotation;
}
}
}
Transform transRightUarm = animator.GetBoneTransform(HumanBodyBones.RightUpperArm);
Transform transRightLarm = animator.GetBoneTransform(HumanBodyBones.RightLowerArm);
Transform transRightHand = animator.GetBoneTransform(HumanBodyBones.RightHand);
if (transRightUarm != null && transRightLarm != null)
{
Vector3 vUarmRightDir = transRightLarm.position - transRightUarm.position;
float fUarmRightAngle = Vector3.Angle(vUarmRightDir, vTposeRightDir);
if (Mathf.Abs(fUarmRightAngle) >= 5f)
{
Quaternion vFixRotation = Quaternion.FromToRotation(vUarmRightDir, vTposeRightDir);
transRightUarm.rotation = vFixRotation * transRightUarm.rotation;
}
if (transRightHand != null)
{
Vector3 vLarmRightDir = transRightHand.position - transRightLarm.position;
float fLarmRightAngle = Vector3.Angle(vLarmRightDir, vTposeRightDir);
if (Mathf.Abs(fLarmRightAngle) >= 5f)
{
Quaternion vFixRotation = Quaternion.FromToRotation(vLarmRightDir, vTposeRightDir);
transRightLarm.rotation = vFixRotation * transRightLarm.rotation;
}
}
}
}