I’m having some trouble with the Mecanim IK Hands following a weapon that is attached to the head of the player. Going horizontally works fine, but when I use the head to aim vertically (using the Mecanim SetLookAt) the hands do not follow the IK objects attached to the weapon.
Extra note: I do have the current layer IK Pass on.
Here’s the code I’m using:
//The objects are the player hand IK targets
var object : Transform;
var object2 : Transform;
var animator : Animator;
//This is where the player's target is stored
var plma : PlayerManager;
function OnAnimatorIK () {
//This part of the code means if the player is aiming using the right mouse button, the head focuses on the target
if(animator.GetBool("Focus")){
animator.SetLookAtPosition (plma.target.position);
animator.SetLookAtWeight(1);
}
animator.SetIKPositionWeight(AvatarIKGoal.RightHand, 1);
animator.SetIKRotationWeight(AvatarIKGoal.RightHand, 1);
animator.SetIKPositionWeight(AvatarIKGoal.LeftHand, 1);
animator.SetIKRotationWeight(AvatarIKGoal.LeftHand, 1);
animator.SetIKPosition(AvatarIKGoal.LeftHand, object2.position);
animator.SetIKRotation(AvatarIKGoal.LeftHand, object2.rotation);
animator.SetIKPosition(AvatarIKGoal.RightHand, object.position);
animator.SetIKRotation(AvatarIKGoal.RightHand, object.rotation);
}
(See below for clarifications.)
-Object is set to Cylinder 1, Object 2 is Cylinder 2
Hands in correct position when player is aiming straight:
When trying to aim vertically:
Thanks,