Issue with Mecanim IK

I’m working with IK for the first time, and can’t seem to get it to work.

In the Animator I have already checked “IK Pass”, and the avatar is configured correctly, but it just isn’t working.

This is the code I have:

using UnityEngine;
using System.Collections;

public class IKTest : MonoBehaviour {
	public Animator anim;
	
	public Transform leftfootAnchor;
	public Transform rightfootAnchor;
	
	void Start(){
		anim=GetComponent<Animator>();
		leftfootAnchor=GameObject.Find("LeftFootAnchor").transform;
		rightfootAnchor=GameObject.Find("RightFootAnchor").transform;
		
		anim.SetIKPositionWeight(AvatarIKGoal.LeftFoot,1);
		anim.SetIKRotationWeight(AvatarIKGoal.LeftFoot,1);
							
		anim.SetIKPositionWeight(AvatarIKGoal.RightFoot,1);
		anim.SetIKRotationWeight(AvatarIKGoal.RightFoot,1);
	}
	
	
	// Update is called once per frame
	void OnAnimatorIK(int layerIndex) {
		anim.SetIKPosition(AvatarIKGoal.LeftFoot,leftfootAnchor.position);
		anim.SetIKRotation(AvatarIKGoal.LeftFoot,leftfootAnchor.rotation);

		anim.SetIKPosition(AvatarIKGoal.RightFoot,rightfootAnchor.position);
		anim.SetIKRotation(AvatarIKGoal.RightFoot,rightfootAnchor.rotation);	
	}
}

I know there are better ways to do things, but I’m just playing around with IK at the moment. Does anyone see where I may have made an error? Or are there common “gotcha’s” that I may have missed?

May be a ridiculous question but are you using pro?

I’m having loads of troubles with mecanim myself at the moment and learned with my various frustrated googlings that IK support is only in pro.

As it happened none of my issues are to do with this, I wasn’t even trying to use IK but thought I’d put it out there anyway, you never know!

There’s two possible solutions that took me a long time to find.

First make sure your avatar is configured as a Humanoid (in the rig settings of the model import).

To repeat, simply click on your model in “Project”…
Click on “Rig”. And be sure to choose “Humanoid”.

Then in the Animator, I’ve found that checking IK pass is not quite enough. You have to have some kind of animations (even if you don’t actually have animations for your character.) My solution to this was to drag the “Default Take” animation from the import, into the Animator. Then add a transition from Any State to Default Take. Nothing changes visually when I click play, but doing this makes the IK Pass actually kick in.