Using Blender 3D's IK system for animating game characters
As of Blender 2.41 Blender 3D has a new and improved skeletal animation
rigging system that is very useful for game animation, but becuase of
the way game characters are often contructed it means having to work
around some of the problems they present when using Blenders IK system.
Limitations of Automatic IK ^
Because setting up IK constraints in Blender can be a tricky thing
to do and often breaks a skeleton if you don't set it up correctly in
relation to what Blender is wanting to see, the Blender developers implemented
an 'Automatic IK' system. Enabled in POSE mode 'Automatic IK'
applies a set of inverse kinetic limitations and constraints based on
the structure of a skeleton; 'child' bones automatically effect a bone
directly above itself and on up through the 'chain';
bone 1 < bone 2 < bone 3 < bone 4
Moving bone 4 above effects all the bones above it in the chain
bone 1 < bone 2 < bone 3 < bone
4
Moving bone 2 above will only effect bone 1. Selecting bone 4 in
this version of the chain will only rotate around it's axis, it can't
move.
The main problem with the autoIK system is that it tends to 'lock'
the position of individual bones in such as way as to prevent those
that aren't part of a direct parent > child chain from being moved
away for their point of origin (point around which a bone rotates) when
grabbed (key 'G').
The video clip below show this; the head bones move as the should;
tilt/rotate back and forth, but the bones associated with the 'eyes'
don't - they should 'free float', move around without restriction -
currently all they can do is rotated around their individual origin
points.
Using IK chains in 'manual' mode ^
Because of this 'problem' (it's not really a problem in the literal
sense but a result of the way IK works) Blender allows the creation
of a skeleton that has a 'special relationship' between bones in a chain;
an IK 'contraint' (limit) can be set that allows IK behaviour up through
a chain whilst not impeding the individual movement/rotation of any
bones not directly contained in part of the IK.
bone 1 < bone 2 < bone 3 < bone
4
Selecting bone 2, as above, will effect bone 1 because it's above
the 'child' bone; selecting bone 4 in this version of the skeleton
will allow the bone to move independently of the other bones and the
IK chain.
The video below shows how setting up the IK chains manually allows
individual bones to be manipulated free from the IK chain; those within
the chain to still effect the whole IK object as normal.
Why is this useful? ^
Game character animation usually has different requirements to that
of rendered animations, as a result skeletons are often set up in a
specific way to compensate for the ability to do one thing but not another;
It's during this process that the limitations of the skeleton become
apparent; bones being 'locked' mean that certain types of movement are
impossible to do using the autoIK system.
By manually setting the IK restrictions the behaviour of a skeletal
rig can be tailored to exactly what is required.
Setting up a manual IK chain ^
As mentioned above, using a rig that's been automatically IK'd doesn't
always yield the desired results, this means assessing a characters
rig and figuring out which bones need to act as an IK 'root' for a chain.
Design note : In instances where this is required it's often
useful to add extra 'control' bones; from a practical point
of view they simply allow easier manipulation of a specific IK chain.
In the example video below two control bones are used; one at the
front of the foot which is used to manipulate the whole leg, allowing
the foot to bend relative to the pose being made. The other extra bone
behind the heal manipulates the leg bones only, allowing the posing
of the leg without touching to foot. In other words;
The 'knee' bone in this setup needs to be 'free floating' - it's the
reason for setting up the IK constraints manually; it's movement is
clearly restricted when it's part of either an Automatic IK chain or
is given it's own IK solver both of which 'lock' it's position.
Adding an IK control ^
Setting up an IK chain manually is pretty straightforward, the only
tricky part is deciding which bones need to have the IK parameters applied
to it - one of the other reasons to use control bones.
Before beginning you need to determine how you want an IK bone chain
to deform; a leg for instance typically starts at the foot and ends
at the hip or upper leg depending on the physical traits of the character
being animated; a dog obviously needs a different set up to a humanoid.
-
In POSE mode select the bone that needs to act as the IK
'root' or 'control' point and from the edit buttons (F9)
add a 'IK Solver' Constraint from the 'Contraints' panel
(usually on the right hand side of the buttons window by default)
- you can name the Constraint where necessary or appropriate but
it's not essential.
-
Still in the Constraints panel, find the 'ChainLen: 0' section
- it defaults to '0' (zero) - and click the small arrows on the
left and right side to increase or decrease the number of bones
the IK chain contains ('1' is the IK control bone itself) - as you
do this you'll notice a thin line move up (or down) the chain as
each bone is subsequently included.
-
Rinse and repeat until the desired IK chain length is achieved.
Once the IK chain has been set up you should find that grabbing (key
'G') the control bone (in POSE mode) will position and pose the
mesh and skeleton relative to the new IK chain. Because the IK's haven't
been 'forced' as they are with Automatic IK, only the IK Solved bones
control the chain which in turn allows ancillary bones to move relatively
freely.