I’ve spent hours trying to fix this to no avail. No matter what I do with this character, I can’t get the hand IK rotation to point in the right direction.
I just want the right hand to rotate point in the direction of a point cast out from the camera.
Here’s a bit of code:
var rightHand : transform; //the right hand bone
function OnAnimatorIK(layerIndex : int){
anim.SetLookAtWeight(lookAtWeight, 0.6, 0.75, 1.0, 0.35);
anim.SetLookAtPosition(lookAtPos);
anim.SetIKRotationWeight(AvatarIKGoal.RightHand, 1.0);
anim.SetIKRotation(AvatarIKGoal.RightHand, Quaternion.LookRotation(lookAtPos - rightHand.position));
Debug.DrawRay(rightHand.position, rightHand.forward, Color.red);
Debug.DrawRay(rightHand.position, lookAtPos - rightHand.position, Color.green);
}
The right hand is pointing in a seemingly completely random direction, as you can see from my debug rays: