Can we apply IK for a specific axis (Example only on Y axis)? If Yes, How?

I am implementing a system in which Hand bone is attached with a Bat. I want to apply IK on Hand bone so that it Bat can reach out Ball-Bat Contact point.
Timing and distance of the shot (in z direction) from contact point and in X direction has been completed. Now I need to adjust Bat’s contact position according to the ball’s trajectory(in Y axis).

For this, I need IK in Y axis only. Because if I use IK for rest of the direction as well my animations for different shots cause problem - intersecting body parts with hand.

Please let me know if anything is available with respect to Y axis IK in Unity 4.3.4.

Yes, use the existing transform as the goal and only draw from your target on the axis that you want to move.


Animator myAnimator = GetComponent<Animator>();
Vector3 leftGoal = new Vector3(transform.position.x, target.transform.position.y, transform.position.z);
myAnimator.SetIKPosition(AvatarIKGoal.LeftHand, leftGoal);


Animator myAnimator = GetComponent<Animator>();
Quaternion goalHandRot = (transform.rotation * Quaternion.Euler(0, target.transform.rotation.y, 0)); // multiplying with quaternions is the equivalent of adding with regular numbers.
myAnimator.SetIKRotation(AvatarIKGoal.LeftHand, goalHandRot);