OnAnimatorIK not called despite same gameObject, IK Pass On for Animator layer.

Hi.

I’ve been adding ranged weapon combat to the 3D Gamekit template, and my OnAnimatorIK method is never called (to get Ellen to lookat the cursor target while aiming). I’ve ensured it’s attached to the same gameobject as the animation controller, I’ve ensured the IK Pass setting is on for the layer in the animator, and I’ve even tried putting the OnAnimatorIK method into the Player controller to see if it would be called there.

Any ideas for what else to try?

Here’s the tutorial I was following. Unity 3D Game Kit Tutorial - Add Ranged Weapon to your game - YouTube
Here’s the code snippet:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class IKController : MonoBehaviour
{
    public Vector3 LookTarget;
    public float Weight;
    public float HeadWeight;
    public float BodyWeight;
    public float MaxAngle;

    Animator _animator;

    private void Awake()
    {
        _animator = GetComponent<Animator>();
        if (_animator.gameObject == gameObject)
        {
            Debug.Log ("Same gameObject for animator and IKController Class.

");
}
}

    private void OnAnimatorIK(int layerIndex)
    {
        Debug.Log ("IKController.cs class ran its OnAnimatorIK method 

");

        if (Weight == 0) return;

        _animator.SetLookAtWeight(Weight, BodyWeight, HeadWeight);
        float deltaAngle = Vector3.SignedAngle(transform.forward, LookTarget - transform.position, transform.up);
        if (Mathf.Abs(deltaAngle) > MaxAngle)
        {
            transform.Rotate(new Vector3 (0, deltaAngle, 0), Space.Self);
        }
        _animator.SetLookAtPosition(LookTarget);    
    }
}

Thank you

Had same issue. Avatar animation type needs to be humanoid… doesn’t work with generic

Same issue. Same gameobject, IK Pass is enabled, doesn’t work.