Search Unity

Question Animation rigging for Inverse Kinematics

Discussion in 'Animation' started by Ominos_Amethyst, Oct 27, 2022.

  1. Ominos_Amethyst

    Ominos_Amethyst

    Joined:
    Dec 15, 2021
    Posts:
    11
    Hi everyone!

    I'm seeking help about the animation rigging package and Inverse Kinematics. I've read a lot of Unity's own documentation about the package and seen a lot of tutorials on youtube, but I can grasp the idea to make what I want to work with the package.

    I have a "leg" (image attached), and I want to move the tip and make every other bone move (IK) in just 1 axis (Constraint). However, I don't fully understand how to achieve it.
    Keep in mind: there is 1 bone that is not visible, it is the tip bone at the far left of the picture.

    Untitled.png

    I know we have the following constraints available for us:
    However, I don't know very well how to utilize them to achieve what I've describe above.Nor do I grasp the concept of adding multiple constrains for 1 leg.

    I did tried to use Two Bone IK Constraint, didn't work, given that my legs has many more bones.
    I also tried to use Chain IK Constrain, it did work, but I was not able to find a way to constrain the rotation axis for each bone.

    Any help in this matter will be extremely appreciated!
     
    brainwipe likes this.
  2. CodeKiwi

    CodeKiwi

    Joined:
    Oct 27, 2016
    Posts:
    119
    I had a similar issue a while ago. I wasn’t able to solve it with the built in constraints and ended up making a basic custom constraint. I think I broke it up into two steps.

    Step 1: distant to target.
    • Two poses (min / max leg distance). Could be a masked animation clip or maybe min/max values for each x axis joint.
    • The lerp value from min to max must always increase the distance e.g. each lerp value should be unique.
    • Given a target IK distance find the lerp value that matches this distance. Could use a lookup table or just calculated at runtime. I’m sure there are better formulas but I just take the mid point a few times e.g. lerp 0.5 (less than target) => 0.75 (greater than target) => 0.625 etc.

    Step 2: aim / look at the target.