Invalid Layer Index on mecanim animator

Hi guys, we’ve been crushing the heads on a wall for 3 days for this problem.
I have a prefab instantiated several times by a script in the game scene. The prefab is composed by 2 objects, one inside the other. The Main_object and the inside_one. The inside_one has got an animator. It works perfectly for a month. We introduce a Network system, and it continue to works fine. 3 days ago the animator system starts to go mad (and we follow).
I know is not professional to say something like this but situation is very strange:
the inside_one has got a Animator component witch its Contoller is called Card_animator_controller and has got two layers and 8 parameters.
In a script linked to the Main_object we use:

public Animator anim;
anim = transform.FindChild("inside_one").GetComponent<Animator>();

if (anim) //we put this just to be sure
    Debug.Log ("Animator Exists!");
	
Debug.Log ("anim controller: " + anim.runtimeAnimatorController.name);
Debug.Log ("anim num of layers: " + anim.layerCount);

anim.SetInteger("NameOfTheParameters", 0);
AnimatorStateInfo infoAboutAniamtor = anim.GetCurrentAnimatorStateInfo(0);

these debugs produce this output:

“Animator exists!”

“anim controller: Card_animator_controller.”

“anim num of layers: 0” (what?)

Waring: Parameter ‘NameOfTheParameters’ does not exist. (what!?)

Error: Invalid Layer Index (WHAT!?)

this is a snapshot of the Card_animator_controller:
[18695-animator+fail.png|18695]

Any help would be grat! Thanks

Something of more interesting: we open a new project, then we open the previous project and everything start again to work properly… O.O

how… what… but above all: why!?

Thanks for the suggestion AbePoppy. Exiting Unity and reloading the project worked for me.

Due to all the problems with Unity/Maverick, my machine froze for 3+ mins and so i powered down my iMac whilst Unity was in Play mode. I reckon this act probably caused the problem.

Anyway thanks

We had a similar problem. Switching project over and back did not solve it.

Turns out the GameObject (third person player avatar) with an animator was disabled at start up and then enabled later when the game is running. It appears that having the third person player avatar (over the shoulder view only)disabled makes the animator not get loaded or generated correctly.

Also the problem only showed up in the both a final and a debug build, but not in the debugger.

To fix this we enabled the whole third person player avatar during the build and then disabled it after start up.

This is probably an effect of the build removing any assets that are not used in the game, and the disable third person player avatar appeared to be ‘not used’ yet is a child GameObject of our overall player GameObject.

AbePoppy, did you find a better way to handle that problem? (i got exactly the same one…).