[SOLVED] OnAnimationIK() not called in 2019.3

Hello!

I’m having great difficulty setting up an IK animation.
Steps I have tried:

  • Setting model to humanoid
  • Apply root motion
  • Set base layer to IK
  • Add another layer for IK
  • Add a simple idle animation

Here is my code. “test” is never logged to the console.

[SerializeField] protected Transform m_LeftHandTarget;
[SerializeField] protected Transform m_RightHandTarget;
        
private Animator m_Animator;

private void Start() => m_Animator = GetComponent<Animator>();

private void OnAnimatorIK(int layerIndex)
{
    Debug.Log("test");

    Assert.IsNotNull(m_Animator);
    Assert.IsNotNull(m_LeftHandTarget);
    Assert.IsNotNull(m_RightHandTarget);
            
    // Left Hand
    m_Animator.SetIKPositionWeight(AvatarIKGoal.LeftHand, 1f);
    m_Animator.SetIKRotationWeight(AvatarIKGoal.LeftHand, 1f);
    m_Animator.SetIKPosition(AvatarIKGoal.LeftHand, m_LeftHandTarget.position);
    m_Animator.SetIKRotation(AvatarIKGoal.LeftHand, m_LeftHandTarget.rotation);

    // Right Hand
    m_Animator.SetIKPositionWeight(AvatarIKGoal.RightHand, 1f);
    m_Animator.SetIKRotationWeight(AvatarIKGoal.RightHand, 1f);
    m_Animator.SetIKPosition(AvatarIKGoal.RightHand, m_RightHandTarget.position);
    m_Animator.SetIKRotation(AvatarIKGoal.RightHand, m_RightHandTarget.rotation);
}

Solved.

Had to set the avatar in the animation component…