HELP - Rigging ik legs, wrong rotation problem

Im using Manuel Bastioni Lab, and i’m trying to implement ik for the legs, so i duplicated the leg bones (thigh and calf, both for left and right legs) and moved to another armature layer, added ik target and pole bones, parented to the root bone, add a ik constraint to those bones, and added an copy rotation from ik legs to the deform armature (the one created with the addon), but when i try to pose the rig, using the ik controls i just created, the legs has a really outwards rotation.

i try setting the pole angle on the ik constraint but apparently is doing what is supposed to do.

here is some images to show what the ik constriant is doing, versus (what i think) is supposed to do.

Note : i’m not a rigger nor animator, and as you may noticed, English is not my native language, so i apollogies if part of this information is not clear.

I added the blend file if someone wants to take a look.

Thanks in advance.


Test_IK.blend (13.7 MB)

On the Copy Rotation constraint. Try turning off (unchecking) the Z rotation.

There are a few things giving this rig problems. Fortunately, all are easy fixes.

  1. Select ik_calf_L and go to bone constraints (Pose mode). Set the pole angle to 90 in the constraint. This will straighten the IK chain. (Pic 1)

  2. Next, under Bone Properties>Inverse Kinematics (Pose mode and the ik bone still selected), lock the Y and Z axes. This will prevent the calf bone from bending or twisting on those axes. (Pic 2)

  1. Select the Pelvis bone (Pose Mode) and unlock the translation (location) axes x, y, and z. This will allow you to position the hips and will be the main location/rotation control for the torso. (Pic 3)

  2. With the armature selected go to Edit Mode. Parent ik_foot_pole_L (This should be renamed to knee_L) to ik_foot_target_L with Keep Offset. The knee almost always points the same direction as the foot. This will help point the knee in the same direction as the foot while still giving you control if you want small deviations in the knee angle.

  3. Parent foot_L bone to ik_foot_target_L bone. This will make the foot IK the main location and rotation control for the foot and leg. It will also introduce a new problem. If the IK foot bone is moved to far away from the leg, the foot will disconnect from the lower leg. The solution is next in #6.

  4. Add a copy location constraint to the foot (foot_L) targeting the shin bone with the IK constraint (calf_ik_L). Change the head/tail option to tail. (Value 1.0) This will keep the foot connected to the tail of the shin while still allowing you to use the IK target bone as a rotation control. (Pic 4)

  1. Select the body mesh. Under modifiers, enable Preserve Volume on the Armature Modifier. This will help the mesh from shrinking.

  2. Repeat all steps (except 7.) for the right side.

Here is the file minus the mesh (to reduce file size) if you need to look at the armature/bones/constraints: Test_IK_DanPro1.blend (533 KB) I’ve left the copy location off the right foot (step 6) so you can see the problem introduced in step 5.

That should do it. Good luck!

1 Like

Thank you very much, that was really detailed, your answer solved the problem

i learned a from your information, i’m always looking for the best practices in any topic that i’m learning/researching, i’m gonna replicate all the changes into my main model.

just for the record (because it could help other people)
when i was trying to solve the ik twist problem i found a python script that automatically calculates the correct ik pole rotation and it output it’s value to the console, here is the link

and the code, just for quick reference

import bpy
from mathutils import *

def signed_angle(vector_u, vector_v, normal):
    # Normal specifies orientation
    angle = vector_u.angle(vector_v)
    if vector_u.cross(vector_v).angle(normal) < 1:
        angle = -angle
    return angle

def get_pole_angle(base_bone, ik_bone, pole_location):
    pole_normal = (ik_bone.tail - base_bone.head).cross(pole_location - base_bone.head)
    projected_pole_axis = pole_normal.cross(base_bone.tail - base_bone.head)
    return signed_angle(base_bone.x_axis, projected_pole_axis, base_bone.tail - base_bone.head)

base_bone = bpy.context.active_object.pose.bones["BASE_BONE_NAME"]
ik_bone = bpy.context.active_object.pose.bones["IK_BONE_NAME"]
pole_bone = bpy.context.active_object.pose.bones["POLE_BONE_NAME"]

pole_angle_in_radians = get_pole_angle(base_bone,
pole_angle_in_deg = round(180*pole_angle_in_radians/3.141592, 3)

BASE_BONE_NAME = ik target
IK_BONE_NAME = bone with the ik constraint
POLE_BONE_NAME = pole bone (knee in this case)

also, i found an addon version of the same code :
link =

so i mixed both ‘solutions’ keeping the pole angle calculated by the addon, and all the setup from DanPro answer and it give me the desired result.

Thank you very much for your time, and btw, i saw your video tutorials before, so it was a nice surprise to see that a person that i follow on youtube answered my question.

thanks dude! keep doing what your doing!