Editor sporadically "forgets" about a Mecanim state machine

Ever since upgrading to 4.2 I’ve encountered a sporadic error. Here’s the scenario.

My default “idle” state is a blend tree that I use to play a collection of idle animations randomly. I do this by using Start as a coroutine, getting the current animation info, yielding the length of that animation clip, picking a new float at random, and assigning that float to a float property in the Animator to kick off a new animation. Something akin to this:

public IEnumerator Start()
{
    this.anim = GetComponentInChildren<Animator>();
    while (true)
    {
        if (IsIdle)
        {
            AnimatorStateInfo info = this.anim.GetCurrentAnimatorStateInfo(0);
            yield return new WaitForSeconds(info.length);
            float newState = Random.Rang(0, 6);
            this.anim.SetFloat("IdleState", newState);
        }
        yield return null;
    }
}

Randomly, this code fails by first stating that 0 is an invalid layer index and that there is no property IdleState. Restarting the editor resolves the issue and if I do a standalone build when the editor is in this forgetful state then the error cascades down to the build - but it’s fine otherwise.

This also seems to coincide with a weird graphical bug where the lines representing transitions in the Animator tab are either missing or very thick.

Update - the graphical bug is not related to Unity dropping the state machine. Does anyone have any thoughts?

I know it’s not much help but just thought I’d chime in with the fact I am now getting this error sporadically too.
Luckily restarting the editor seems to fix it but it’s still a bit worrying.

Exact same scenario here. Worse, however, if that if you build executables while this bug is happening in the editor, the error will propagate to your standalone. I think we need a bug, I’m on it.

Case 573418

Any movement from Unity on this issue? I’m seeing the exact same thing. Unity 4.2.2f1. Restarting the editor and rebuilding to devices fixes the issue, only to have it come back once in a while.

BUMP
BUMPITY
BUMP

Helloooooo Unity folks? Can we please get some support here? Even telling me to go climb a tree would be more helpful than silence!

Please go climb a tree. :slight_smile: Just kidding.

Just sent this along with the bug number to QA. You wouldn’t have happened to try it in 4.3?

I encountered this same issue today. I’m using 4.3.0f4 and restarting Unity fixed it for some models. Restarting it again fixed it completely.

Hello,

I am getting similar error, restarting Unity does not help. While running Stealth demo at some point mesh preview and curves on the right (when I click on transition) become distorted. I am running it on Windows 8

Here is screenshot

Update: Opening another project then reopening Stealth demo seemed to fix issue. Weird…

Another update: When I load Done\DoneScenes\DoneStealth scene it gets broken again :slight_smile:

We are seeing this same bug (the original one about Animator having an invalid layer) and it mostly happens only on a build (Android), but I('ve had it happen in the Editor as well. I didn’t need to restart the editor to “fix” it, but just stopping and restarting and it works again. No idea how to make it happen again in the Editor.

Now, we’re also seeing the symptoms of the bug (animations not playing at all) but without any errors at all. doing traces reveals the animator does transition to the proper state, but the state never actually starts playing, and the character is stuck in mecanim’s default pose, mid-trough the ground.

We’re using 4.3.1f1. I don’t know if this is because of an update, as we’ve just upgraded our animation system to Mecanim after 4.3 was introduced (though I now kinda wish I had waited a bit longer…)

Anybody seeing similar issues that can chime in and maybe we find a reliable work-around? Right now it’s hit or miss if a build will work on the device at all or not.

Also, where can I check the status of the reported bug? (Case 573418 )

I’ve just started getting this, in mecanim theres definately one layer, I have

void Start () {
anim = GetComponent();
anim.SetLayerWeight(1,1);

}

Was working fine, tried restarting the editor and is still an issue, any ideas anyone?

I also just tried create new project with the dodgey one open and it wiped my hierarchy…nice

I’m also having the same “Invalid layer index” bug on Android. I have 2 layers.

It still happen to me! But only when i create a web player build… I have unity 4.5.1f3 and a pro licence. This is very random and very annoying, please fix this!

I’m getting Invalid Layer Index, as well as Paramater ‘’ does not exist on Animators that were correctly animating characters just seconds before, during the same run of our game in the editor. (v 4.5.3f3). The errors are visible in the Unity Editor, which is serving as a client to a Unity Player running the same build, as a stand alone built server, on the same computer.

BUMP BUMP BUMP

We are experiencing the same issue as well. We’ve seen this problem periodically and this bug is causing us lost time. It’s clear that others are experiencing the same behaviour and whilst closing / reopening Unity is a valid way to fix the problem we often don’t see the issue until deep into testing locally which is a real headache.

Can we get some traction on this or at least an update on the status? Or - in the very least an acknowledgement of the bug and why it’s occurring.

I’m using Unity Pro 4.5.1f3.

Thanks!

  • Toby.

Experiencing the same thing as well, opening another project, then returning helps.

I too have been experiencing this problem erratically in all versions of unity since 4.1.2, I can’t seem to get a 100% repro with it, but certain things seem to exacerbate it.

Most of the time it happens when building (I’m building for windows), though as I speak it’s just happened in the editor after a build.

The animator seems to become corrupt in some way and any operation on it spits out an “Invalid Layer Index” error or “Invalid Hash” error. The visual of the animator itself seems to be very erratic. The skinned meshes end up in their bind pose when it happens (though in 4.1.2 it was a lot worse, the bones would fly off into a random space, now it just goes to bind pose in 4.5.3)

Having the animator window open at build time seems to cause it to happen, also the animator I have is rather complicated (several layers, a few sub states, zero-time transitions) and I think this causes some problems, but it happens on simpler animator controllers too, but they do share the zero-time transitions, so that may have something to do with it.

I can’t seem to get a 100% repro with this unfortunately, but because of this erratic nature, it could have something to do with the animator interrupting serialization or something, not sure how it all works internally.

I have never had this happen in editor but I have had it happen on a build a lot of times. Like you said, it seems to be intermittent, in my case rebuilding fixes it. You do a build and it’ll be fine, do it again and it’ll be broken, do it again and it’ll be fine. I have not managed to produce a reliable repro project or even narrow down what on earth is going on. It’s been happening since long before our Animator Controller actually got complicated. And on top of that we keep losing the any state transitions in Editor, but that is a known issue with a known workaround until Unity fixes it.

Hello anyone knows if this was solved? We just had this problem, and worse, we sent the version for our Publisher (because here it was not happenning, and then started out from nowhere). We are still using Unity 4.5.2
Thanks