Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

IK weird results

Discussion in 'Animation' started by chainsawpenguin, Oct 28, 2019.

  1. chainsawpenguin


    Sep 28, 2014
    Good evening, team!

    I'm using an IK pass to set my left hand position for a two-handed weapon that is parented to the right hand.

    Here's my code:

    Code (CSharp):
    2.         void OnAnimatorIK()
    3.         {
    4.             myAnimator.SetIKPositionWeight(AvatarIKGoal.LeftHand, 1.0F);
    5.             myAnimator.SetIKRotationWeight(AvatarIKGoal.LeftHand, 1.0F);
    6.             myAnimator.SetIKPosition(AvatarIKGoal.LeftHand, myLeftHandTarget.transform.position);
    7.             myAnimator.SetIKRotation(AvatarIKGoal.LeftHand, myLeftHandTarget.transform.rotation);
    8.             Debug.Log("My LeftHand Target is " + myAnimator.GetIKPosition(AvatarIKGoal.LeftHand).ToString()
    9.                 + " And my Left Hand is at " + myAnimator.GetBoneTransform(HumanBodyBones.LeftHand).transform.position.ToString());
    10.             myAnimator.SetLookAtWeight(lookWeight, bodyWeight, 1, 1, 1);
    11.             myAnimator.SetLookAtPosition(myAimDebugObject.transform.position);
    13.         }
    However, I can see for sure that the left hand is decidedly not where the left hand target is. Is the SetLookAt (which alters the body rotation) affecting the hand ik? And if so, how can i get the hand to go where I want it to go and ignore the body rotation?