- Home /
Mecanim hand IK
Hi there, I'm working in Mecanim and now I'm trying to use built in inverse kinematics for hands. But I have strange character behaviour in result: instead of touching the assigned object he streches the arm streight up all the time (see it on the screenshot). Any ideas? Thanks in advance.
When I'm trying my ik script on the Unity default character (Dude), everything's working correctly. So I think it's something to do with avatar settings. I checked them, but it seems that everything is ok, it's done by the example of unity default avatar.
Can you post your ik script?
What happens if you drop your avatar into the I$$anonymous$$ example scene in the $$anonymous$$ecanim Example Scenes project and use it ins$$anonymous$$d of the spiky-haired guy? The scene has some spheres that you can move in the Scene View. The avatar's hands and feet should follow the spheres.
void OnAnimatorI$$anonymous$$()
{
if (_animator)
{
if (ikActive)
{
_animator.SetLookAtWeight(1.0f);
_animator.SetLookAtPosition(_hit.point);
_animator.SetI$$anonymous$$PositionWeight(AvatarI$$anonymous$$Goal.RightHand, 1.0f); _animator.SetI$$anonymous$$RotationWeight(AvatarI$$anonymous$$Goal.RightHand, 1.0f);
_animator.SetI$$anonymous$$PositionWeight(AvatarI$$anonymous$$Goal.LeftHand, 1.0f);
_animator.SetI$$anonymous$$RotationWeight(AvatarI$$anonymous$$Goal.LeftHand, 1.0f);
_animator.GetI$$anonymous$$PositionWeight(AvatarI$$anonymous$$Goal.RightHand));
if (_bent != null)
{ _animator.SetI$$anonymous$$Position(AvatarI$$anonymous$$Goal.RightHand, _gun.position); _animator.SetI$$anonymous$$Rotation(AvatarI$$anonymous$$Goal.RightHand, _gun.rotation); _animator.SetI$$anonymous$$Position(AvatarI$$anonymous$$Goal.LeftHand, _bent.position); _animator.SetI$$anonymous$$Rotation(AvatarI$$anonymous$$Goal.LeftHand, _bent.rotation);
}
}
else
{
_animator.SetI$$anonymous$$PositionWeight(AvatarI$$anonymous$$Goal.RightHand, 0.0f); _animator.SetI$$anonymous$$RotationWeight(AvatarI$$anonymous$$Goal.RightHand, 0.0f); _animator.SetI$$anonymous$$PositionWeight(AvatarI$$anonymous$$Goal.LeftHand, 0.0f); _animator.SetI$$anonymous$$RotationWeight(AvatarI$$anonymous$$Goal.LeftHand, 0.0f);
}
}
}
Sorry, I'm not fully aware of how make formatting here...
I placed my character in the unity tutorial scene (mecanim tutorial), the robot from tutorial works fine with my script attached. But my robot placed on the scene again streches his hand... I search for people with the same problem and the only explanation that I can find is scale mismatching (my character has scale 100 for x,y,z and effector 0.03). But I don't know what to do anyway
Your answer
Follow this Question
Related Questions
Best way to do gun reload and move sway 0 Answers
Mecanim position specific bone 0 Answers
Mecanim OnAnimatorIK() execution order 1 Answer
Mixing Unity Mecanim and Scripted Bones/States 1 Answer
How to let humanoid hold gun? 0 Answers