Mecanim/Animator SetLookAtPosition not working

I have a character controlled by a Mecanim Animator. I want to be able to precisely position the character’s head.

    public Transform lookTransform; // An object set in the editor, not null
	
	// Update is called once per frame
	void Update () {
		if (lookTransform != null) {
			Animator animator = GetComponent<Animator>();
			animator.SetLookAtPosition(lookTransform.position);
			animator.SetLookAtWeight(1.0f);
		}
	}

This results in no effect whatsoever. As far as I can tell, I’m using the same code from the Mecanim example project (the one where the robot shoots lasers at the floating sphere). I’m using Unity Free; is that possibly the reason?

OnAnimatorIK will only work if it’s on the same GameObject as the Animator component.

First, write this in Start() of any script for Pro version

bool hasPro = UnityEditorInternal.InternalEditorUtility.HasPro();
print ("Unity Version Pro: " + hasPro);

If it returns true, then reconfirm by running this

void OnAnimatorIK (int layerIndex) {
   print ("OnAnimatorIK - running");
}

As, the above code only runs in Pro version.

Remember that OnAnimatorIK is a callback function, so it must be on the object having animator component.
Also, remember that in your animator controller, in your animation layers IK Pass should be checked.


Hope, it will save someone’s time finding problem on IK.

#And look here:

http://answers.unity3d.com/answers/650502/view.html

I apparently have a nasty habit of answering my own questions.

It would appear by looking at the Unity Store that the head look functionality is limited to the Pro version of Unity. This is the only place I have found any information about it; there is no mention of the feature being Pro only in the scripting documentation. There is also no warning within Unity when attempting to call this Pro-only feature; it merely fails silently.

It looks like I’m going to be building my own.