Animancer v6.0 is currently available for testing.

Inverse Kinematics

The most common form of animation uses Forward Kinematics where each bone is given a specific rotation which it adds to the rotation of its parent. So you rotate the shoulder and the elbow moves accordingly because it is a child of the shoulder. You rotate the elbow and the hand moves accordingly. And so on.

But sometimes it is desirable to directly control the end point instead. With Inverse Kinematics, you specify the desired position of a hand or foot and the IK system figures out how to rotate the bones to get it there. This can be used to have a hand reach a specific point such as a door handle or adjusting the height of a foot to match the terrain.

Animancer allows you to use Unity's inbuilt Humanoid IK system in mostly the same way you would with Mecanim. The main difference is that you enable it by setting AnimancerNode.ApplyFootIK or AnimancerNode.ApplyAnimatorIK on a state or layer instead of enabling it with toggles in an Animator Controller.

You can also enable/disable IK using the Context Menu Functions in the AnimancerComponent Inspector for testing purposes (the setting will not be stored in the scene or prefab, so you will always need to enable Ik with a script to use it at runtime).

The Inverse Kinematics examples demonstrate the use of this feature.

Foot IK

Foot IK allows Unity to make the character's feet more closely match the original animation's positions after retargeting it from the animation's rig to the model's rig. This can help reduce foot sliding caused by differing rig proportions, but it also often has undesirable results so it should be selected on a case by case basis.

void EnableFootIK(AnimancerComponent animancer, AnimationClip clip)
{
    // Enable Foot IK for all new states by default:
    animancer.Playable.DefaultApplyFootIK = true;

    // Enable Foot IK for all states and set the default:
    animancer.Playable.ApplyFootIK = true;

    // Enable Foot IK for a specific layer:
    animancer.Layers[0].ApplyFootIK = true;

    // Enable Foot IK for a specific state (and any children if it is a mixer):
    var state = animancer.States.GetOrCreate(clip);
    state.ApplyFootIK = true;
}

This is equivalent to the Foot IK toggle in an Animator Controller state:

Internally, when Unity creates an AnimationClipPlayable it actually starts with the Foot IK enabled by default. Unity Support says this is "by design" since they believe it looks better, however this default is not mentioned anywhere in the Unity Manual and many users complained about the foot pose being different from the original animation when using Animancer so it simply disables Foot IK when the playable is created (unless you set AnimancerPlayable.DefaultApplyFootIK = true beforehand).

IK Pass

The IK Pass causes Unity to call the OnAnimatorIK(int layerIndex) method every frame in any scripts attached to the same object as the Animator. Unfortunately, due to limitations in the Playables API Unity will only ever call OnAnimatorIK with the layerIndex = 0.

void EnableIKPass(AnimancerComponent animancer, AnimationClip clip)
{
    // Enable IK Pass for all new states by default:
    animancer.Playable.DefaultApplyAnimatorIK = true;

    // Enable IK Pass for all states and set the default:
    animancer.Playable.ApplyAnimatorIK = true;

    // Enable IK Pass for a specific layer:
    animancer.Layers[0].ApplyAnimatorIK = true;

    // Enable IK Pass for a specific state (and any children if it is a mixer):
    var state = animancer.States.GetOrCreate(clip);
    state.ApplyAnimatorIK = true;
}

This is equivalent to the IK Pass toggle in an Animator Controller layer, except that due to limitations in the Playables API the layerIndex Unity passes into OnAnimatorIK will always be zero:

Animated Properties

This is a Pro-Only Feature: you can try it out in the Unity Editor with Animancer Lite, but it will not be available in runtime builds unless you purchase Animancer Pro.

It is quite common to use an AnimationCurve in an AnimationClip to control the weight of the IK so that some parts of the animation use more IK than others. 0 means the limb will be fully controlled by the animation while 1 means the IK system will be fully in control, with anything inbetween giving a proportional amount of control.

Normally to access a custom curve at runtime you would add a float parameter with the same name to your Animator Controller so that Unity will automatically update it and you can then read the value from that parameter to control the weight of the IK each frame. In Animancer, this is done using an AnimatedProperty instead:

[SerializeField] private AnimancerComponent _Animancer;

// Requires Unity 2019.1+. See below for details.
private AnimatedProperty _LeftFootWeight;

private void Awake()
{
    _Animancer.Layers[0].ApplyAnimatorIK = true;

    _LeftFootWeight = new AnimatedProperty(_Animancer, AnimatedProperty.Type.Float, "LeftFootIK");
}

private void OnAnimatorIK(int layerIndex)
{
    float currentWeight = _LeftFootWeight.FloatValue;

    ...
}

The Uneven Ground example demonstrates the use of this feature in more detail.

Exposed Curves

The AnimatedProperty class uses the Animation Job system introduced in Unity 2019.1 and there is no straightforward way of accessing custom curves at runtime in older versions of Unity. Previous versions of Animancer worked around this problem using an ExposedCurve class which can now be downloaded from here. That class avoids problem by extracting a chosen curve from an AnimationClip in the Unity Editor and serializing it in the ExposedCurve so it can be evaluated at runtime:

  1. Create an ExposedCurve using Assets/Create/Animancer/Exposed Curve.
  2. Assign the AnimationClip containing the curve and enter the Property Name of the curve.
  3. Any future changes to the original curve in the AnimationClip will automatically be retrieved by the ExposedCurve. Unfortunately it is not currently possible to edit the curve using the ExposedCurve Inspector. You need to edit the curve in the Animation window or the model import settings.
  4. Reference that asset in your script and evaluate it during OnAnimatorIK to determine how much weight to give the IK system during each frame:
[SerializeField] private AnimancerComponent _Animancer;
[SerializeField] private ExposedCurve _LeftFootWeight;

private void OnAnimatorIK(int layerIndex)
{
    var currentWeight = _LeftFootWeight.Evaluate(_Animancer);

    ...
}

Note that an ExposedCurve can only evaluate the target curve from a single animation where an AnimatedProperty will automatically Blend the value according to all the animations currently playing.