how to do IK on legs?

hello!,

I followed a tutorial on youtube for leg ik, and it worked, but when i would move my character up on the z axis and then try and move him back down, his leg stays in the air and the rest of his body is the only thing that goes down…HELP!!! :spin:

p.s. i attached the blend file.

Attachments

test.blend (200 KB)

The foot-bone in your rig is parented to the shin-bone, AND it is the shin-bones IK-target, which is no good.
Secondly, currently the hip bone is top of the hierarchy, which leeds to problems with legs and IK:

So, before we get to the leg/foot problem:
Fist create another bone in the Armature at the center bottom of the character (between the feet). Parent the hip-bone to that bone. Name that top bone appropriately (I usually call it GRAMMA since it is the mother of all bones in the hierarchy).

Translation with the leg/foot ANIMATION CONTROL:
Create another bone (extrude) from the heel (end of shin-bone, beginning of foot-bone), and parent it to the GRAMMA. Make sure it isn’t deforming the mesh by un-checking DEFORM in the bone settings (same for the GRAMMA).
Since this bone is the ANIMATION CONTROL of the leg (and foot), make it the new IK target for the leg IK (your shin-bone).
Make sure the foot-bone is still parented to the shin-bone, but un-check ‘Inherit Rotation’ in the foot-bone settings (explanation next).

Control foot rotation with the ANIMATION CONTROL bone:
Apply a ‘Copy Rotation’ Constraint to the foot-bone with the same ANIMATION CONTROL bone that is the IK target for the leg.
In the constraint settings change both to ‘Local Space’, and if necessary, invert X,Y,Z axis for correct rotation behavior.

Now the leg/foot can be translated with the ANIMATION CONTROL bone, and the feet stay rooted while moving the hip-bone. Rotating the ANIMATION CONTROL also rotates the foot, since ‘Inherit Rotation’ from the parent (shin-bone) is un-checked.
Because the ANIMATION CONTROL bone is parented to the GRAMMA, and the foot-bone is parented to the shin-bone, the geometry won’t be torn apart when the hip is moved beyond the length of the leg.

Don’t forget to also create Pole Target bones for controlling the orientation of the knees (add them in the Pole Target filed of the IK constraint).
Foot setup (heel, toes animation) is another story which you can find tutorials about on the Internet.

your suggestion worked! thanks alot!