0
\$\begingroup\$

I'm trying to make character elbow movable like the hand. In my case, is not moving at all. Is it from my script or something else ?

public GameObject rightHandObj, leftHandObj,rightElbowObj,leftElbowObj;
public Transform IK_point;
private Animator mAnimator;


private void Start()
 {
    mAnimator = this.GetComponent<Animator>();
}

private void OnAnimatorIK()
 {


    if (mAnimator)
    {

        mAnimator.SetLookAtWeight(1.0f, 0.5f);
        mAnimator.SetLookAtPosition(IK_point.position);

        if (ikActive)
        {
            if (rightHandObj != null)
            {
                mAnimator.SetIKPositionWeight(AvatarIKGoal.RightHand, 1);
                mAnimator.SetIKRotationWeight(AvatarIKGoal.RightHand, 1);
                mAnimator.SetIKHintPositionWeight(AvatarIKHint.RightElbow, 1);

                mAnimator.SetIKPosition(AvatarIKGoal.RightHand, rightHandObj.transform.position);
                mAnimator.SetIKRotation(AvatarIKGoal.RightHand, rightHandObj.transform.rotation);
                mAnimator.SetIKHintPosition(AvatarIKHint.RightElbow, rightElbowObj.transform.position);


            }

            if (leftHandObj != null)
            {
                mAnimator.SetIKPositionWeight(AvatarIKGoal.LeftHand, 1);
                mAnimator.SetIKRotationWeight(AvatarIKGoal.LeftHand, 1);
                mAnimator.SetIKHintPositionWeight(AvatarIKHint.LeftElbow, 1);

                mAnimator.SetIKPosition(AvatarIKGoal.LeftHand, leftHandObj.transform.position);
                mAnimator.SetIKRotation(AvatarIKGoal.LeftHand, leftHandObj.transform.rotation);
                mAnimator.SetIKHintPosition(AvatarIKHint.LeftElbow, leftElbowObj.transform.position);

            }
        }
    }

}

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.