2 Bone IK in Unity

EDIT - I think.. it is best to have a standard FK hierarchy and multiple Rig Builders, which each exist one bone above the root of each 2 joint IK chain. Eg. the clavicle would have the rig builder and the L_HAND in my example below would sit underneath it.

|- CLAVICLE 

|    | -SHOULDER

|    |    |  -ELBOW

|    |    |    |-HAND

|    |-runtime rig, containing the 2 bone IK & rig components

 This hierarchy allows the clavicle to rotate and behave as it should in "standard" rigs.


------------------------------------------------------------------------------------------------------------------

 

 

At time of writing, Trump just got beaten by Biden! Good times.... and Unity 2020 has an "in preview" rigging package, which lets us implement simple IK setups. Now there are some third party commercial plugins we could look at - Final IK is probably the top dog at the moment.. Fast IK is free and actually quite good (BUT, for ME, the scripts caused build errors. I'll look into maybe fixing it if I feel like it's necessary).

Anyway - add the Animation Rigging package to your project.

This post assumes you have some sort of hierarchy setup to control your character/thing.You don't need joints for this, unless you require some other aspect of them. A simple 3 box setup, with correct pivots (or empty gameobjects serving as pivots will suffice). We'll pretend it's an arm, so we have shoulder, elbow and wrist. Also create two other objects, a "target" and "hint". These two should sit outside of the hierarchy.

To the shoulder, add a "rig builder" component. Within the hierarchy (eg, just under the shoulder), add an empty gameobject, call it something (eg: L_HAND) and add a "2 bone IK constraint" and "rig" component.

Within the constraint component, assign the appropriate gameobjects - shoulder to the root, elbow to mid and wrist to tip. Also assign the target and hint to the labelled boxes. The target is essentially your hand IK controller. The "hint" is a pole vector.

 Now in the shoulder's rig builder component, select the L_HAND as one of the rig layers.

If you hit PLAY now and move the target object around, you should see the IK chain behaving correctly! You can rotate the target and the "wrist" will behave nicely. Move the "hint" pivot around too.

From what I can tell, the root of the character should contain the rig builder component.

Comments

Popular posts from this blog

setting VFX graph properties using C#