top of page
  • Yves "Jack" Albuquerque

Basic: Unity IK

IK (Inverse Kinematic) is an animation technique. Using IK, an animator moves the end-effector bone based in a desired position instead of rotate each bone individually as used on FK (Forward Kinematic). All intermediary bones are dynamically adapted in order to achieve this goal.

There's nothing new in IK, actually is an old technique primary used in robotics. In 1998, Jurassic Park: Trespasser, brings IK to Real Time. IK involves some processing power, what explains why this take so long to be used in Real Time. Until the past generation, we avoid to use IK, limiting it's use to a few simultaneous animations due this processing cost.

You can calculate intermediary bones positioning using trigonometry in a 3-bone based structure, however, in more complex situations, algorithmic as CCD (Cyclic Coordinate Descent), Fabrik (Forward And Backward Reaching Inverse Kinematics) and L-BFGS-B (Generic Evolutionary Inverse Kinematics) are used.

Nowadays, IK usage is not a big deal. Unity brings a built-in solution associated with humanoid Mechanism system. As most other game engines, Unity used Fabrik algorithm internally.

So the first requirement to use Built In IK in Unity is use Humanoid system (import as Humanoid and use Animator). This is a totally shame and that's why there's so many IK solution at the Asset Store. Not sure why Unity never created a component for IK. Even the old (but awesome) Locomotion example used on Unity 3 and 4, has some IK solutions on it.

The second requirement is to enable IK Pass flag into your animator Layers. Some developer like to use a dedicated Layer to deal with IK. This make some sense if you think about performance. Also, by enabling this flag, a callback called OnAnimatorIK will be called into the object using this Animator.

IK functionalities are accessed through the Animator and should be done inside the OnAnimatorIK callback.

PS: Animator's "Look At" don't use IK, however, as a procedural behavior used in similar way I've added here at this example.

You can see the setup and result on the video below and download the entire code here.

643 visualizações0 comentário

Posts recentes

Ver tudo
bottom of page