# OnAnimatorIK(int)

> Callback for setting up animation IK (inverse kinematics).

## Definition

* **Type:** Method
* **Namespace:** [UnityEngine](/engine/6000.5/script-reference/unityengine.md)

## OnAnimatorIK()

```csharp
public void OnAnimatorIK(int arg0)
```

### Parameters

**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)):&#x20;

### Remarks

`OnAnimatorIK` is called by the [Animator](/engine/6000.5/script-reference/unityengine/animator.md) component immediately before it updates its internal IK system. This callback can be used to set the positions of the IK goals and their respective weights. `OnAnimatorIK` is only called if the following requirements are met: - The Animator component must reference an [Avatar](/engine/6000.5/script-reference/unityengine/avatar.md) configured as Humanoid. Generic or Legacy avatars do not support IK. - The Animator Controller layer you want to process IK on must have the IK Pass option enabled. - The Animator component must be enabled and playing an animation on the GameObject. - The script containing `OnAnimatorIK` must be attached to the GameObject with the Animator component. Common uses include: - Setting the position and rotation of IK goals, such as hands and feet, to interact with objects or reach targets in the environment. - Blending between animation-driven and IK-driven motion by adjusting IK weights. - Creating procedural animations, such as looking at a target or reaching for an object. Additional Resources: [AnimatorController](/engine/6000.5/script-reference/unityeditor/animations/animatorcontroller.md), [Avatar](/engine/6000.5/script-reference/unityengine/avatar.md), [Animator](/engine/6000.5/script-reference/unityengine/animator.md).

### Examples

```csharp

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour
{
    float leftFootPositionWeight;
    float leftFootRotationWeight;
    Transform leftFootObj;

    private Animator animator;

    void Start()
    {
        animator = GetComponent<Animator>();
    }

    void OnAnimatorIK(int layerIndex)
    {
        animator.SetIKPositionWeight(AvatarIKGoal.LeftFoot, leftFootPositionWeight);
        animator.SetIKRotationWeight(AvatarIKGoal.LeftFoot, leftFootRotationWeight);
        animator.SetIKPosition(AvatarIKGoal.LeftFoot, leftFootObj.position);
        animator.SetIKRotation(AvatarIKGoal.LeftFoot, leftFootObj.rotation);
    }
}
```
