Game Development Reference
In-Depth Information
How it works...
The list we defined contains the bones that we want to have at the end of the chain. These
are the bones that the control will try to get as close to the target position as possible. To
get the feet at a suitable angle, we not only need the feet but also the toe bones. By trying to
align both the feet and the toe bones, we get a better approximation of the ground below.
Unlike most of our controls, we don't actually do anything in the controlUpdate meth-
od. This is because the actual alignment is passed on to KinematicRagdollControl .
Instead, we do a check each time the control is enabled and see what positions it should try
to reach.
For each of the tip bones, we shoot a ray straight up, using an offset to start some way be-
low the ground. The reason we don't just use the bones' position and check below it is be-
cause we can't be sure that the model is completely above the ground. Animations might
very well push body parts inside the ground, and if we then shot a ray downwards, we
wouldn't hit what we want.
Once a target position is found, we supply the bone to KinematicRagdollControl .
Along with this is also an integer that defines how long the chain of bones should be that it
can modify when trying to reach the target.
There are some more values we supply to KinematicRagdollControl . The
IKThreshold value is the distance from the target point where it is okay for it to stop
trying.
LimbDampening can be used to effect how much a bone should move in relation to oth-
ers. Imagine we're stretching out for something on our desk. Our forearms are most likely
to perform bigger movements (rotation-wise) than our upper arms. If limbDampening is
lower than 1.0, the bones higher up in the chain (and likely bigger) will move less with
each update than those closer to the tip bone.
IKRotSpeed defines the rotation steps the control should apply with each turn. A higher
value means it'll get closer quicker, but it also means the margin of error becomes higher.
All these values require tweaking to get them right for the application. Implementation is
just the first step. The KinematicRagdollControl method also needs some setting
up, most importantly, it needs to know the bones it should be able to control.
Search WWH ::




Custom Search