- Home /
 
Unable to set IK position with an offset, it keeps jittering.
I have a character holding a stick with left hand. I am using IK to make the stick hit a target position. When I position left hand at target position, it works fine. But, I need to offset the hand such that the end of the stick hits the target position. For this, I have put an empty game object as a child at the end of the stick, and offset it like below, but the hand just keeps jittering like crazy. I know it is quite possible to do that, but somehow I seem to be missing something. Please help me!
     [SerializeField] private GameObject target;
     private Vector3 leftHandPosition;
     private Vector3 hitChildPosition;
     
     private void OnAnimatorIK(int layerIndex)
     {
             Vector3 t = target.transform.position - (hitChildPosition - leftHandPosition);
             animator.SetIKPosition(AvatarIKGoal.LeftHand, t);
             animator.SetIKPositionWeight(AvatarIKGoal.LeftHand, 1);
     }
     
     private void LateUpdate() 
     {
             hitChildPosition = BatHit.transform.position;
             leftHandPosition = animator.GetBoneTransform(HumanBodyBones.LeftHand).position;
     }
 
               Check out this image below, I want the Hit Point Position to be placed at Target Position. 
Your answer
 
             Follow this Question
Related Questions
Multiple Animation Controllers 1 Answer
My Animator is acting Strange 1 Answer
Multiple Game Objects with single Animator? 1 Answer
Make animation go to child.,Make animation go to child 1 Answer