Hello world!
Frans van Berendonk / News / Easy Inverse Kinematics

Easy Inverse Kinematics

I've always thought IK implementations were mathematicly too complex for me. However, Unity supports IK for humanoid avatars out of the box and I couldn't resist at least trying it out.

I'm happy to say that after an evening of tinkering, I've been able to get IK working pretty well! While a good implementation needs some animation layering to finish it off, I've already been able to animate IK weights. That way hands and feet can move and rotate fluidly, and at a later time I can implement some easing on every individual limb if needed. I've yet to decide what I will use IK for in my prototype, but I'm guessing it will come in very handy once I get around to implementing combat and cutscenes.

Thanks to a few helpful souls on the Unity forums I also managed to implement a few animation layers as well. With IK you can affect the position and rotation of an IK target such as a hand, but any fingers in that hand will still follow the base animation layer. By adding another layer on top and having transitions fire via parameter, I've implemented the option to dictate the position of the fingers: making a fist for example, or a rude gesture. Or just follow along with the base layer if no override is required. Powerfull stuff!

I've found a really good tutorial on how to get humanoid avatars to apply leg IK relative to the ground:

Realistic foot placement using Inverse Kinematics