I’m not very good at anything animation, but I’m making a 2.5D shooter. So I needed to add some IK to get the arms/guns to rotate with the mouse. I have the mouse rotation working, but the arms follow super weird. I got the basics of IK working (like it does stuff, just it rotates weird). I need some pointers on how to make it rotate and point at a target object.
Is there a good way to approach this problem? Do I need to edit the anim.SetIKHint’s? Or just the basic anim.SetIK (what I currently have)?
Heres my code so far (pretty much just what the docs have):
if (ikActive)
{
if (lookObj != null)
{
anim.SetLookAtWeight(1);
anim.SetLookAtPosition(lookObj.position);
}
if (rightHandObj != null)
{
anim.SetIKPositionWeight(AvatarIKGoal.RightHand, 1);
anim.SetIKRotationWeight(AvatarIKGoal.RightHand, 1);
anim.SetIKPosition(AvatarIKGoal.RightHand, rightHandObj.position);
anim.SetIKRotation(AvatarIKGoal.RightHand, rightHandObj.rotation);
}
}
else {
anim.SetIKPositionWeight(AvatarIKGoal.RightHand, 0);
anim.SetIKRotationWeight(AvatarIKGoal.RightHand, 0);
anim.SetLookAtWeight(0);
}
The rightHandObj and lookObj are both set to a moving target that rotates with the mouse, my arms just don’t rotate right (they do like left/right/all bendy instead of up/down like I want.
Any help would be greatly appreciated!