- Home /
Mecanim hand IK with bodyWeight problem
So I have a mecanim character with 2 layers:
Base Layer: Handles Walking
UpperBody: Handles Arms to seperate their animations from baselayer (Mask attached, Mode: Override and IK Pass checked)
My character can hold a rifle. Each rifle has an LeftHandTarget for its LeftHand, to match the hands position to the rifle.
Snippet from WeaponHandler.cs:
void OnAnimatorIK(){
if (currentWeapon && currentWeapon.leftHandIKTarget && !reload) {
Transform target = currentWeapon.leftHandIKTarget;
anim.SetIKPosition(AvatarIKGoal.LeftHand, target.position);
anim.SetIKRotation(AvatarIKGoal.LeftHand, target.rotation);
anim.SetIKPositionWeight(AvatarIKGoal.LeftHand, 1);
anim.SetIKRotationWeight(AvatarIKGoal.LeftHand, 1);
} else {
anim.SetIKPositionWeight(AvatarIKGoal.LeftHand, 0);
anim.SetIKRotationWeight(AvatarIKGoal.LeftHand, 0);
}
}
It works fine, however if I set bodyIKweight to any other value above 0 (here 0.25f) the rifle will turn with the body and so the LeftHandTarget, but the characters left hand stays at the same position as if bodyIkweight is 0.
Snippet from CharacterMovement.cs:
void OnAnimatorIK(){
if(lookTarget && !aiming){
anim.SetLookAtPosition(lookTarget.position);
anim.SetLookAtWeight(1f, 0.25f, 0.3, 0.5, 0.7f);
}
}
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612093513im_/https://answers.unity.com/themes/thub/images/avi.jpg)