Mecanim issue Animator has not been initialized.

I have a character exported to an assetbundle with an Animator component on it, which already has an Animator Controller attached.

When I load my character into the game and GetComponent on the Animator, then try to set any properties on it (SetBool, SetFloat etc) I get the error “Animator has not been initialized.”

I don’t see anything in the documentation and the only other reference to this error message on the forums is 3 weeks old and didn’t resolve it.

What does this message mean and how does one initialize the Animator?

In my short experience of the system, those are just warnings (not show-stopper errors) and usually just mean the mecanim display panel will not update in real-time when in game-mode; so you won’t see all the transitions and parameters react as events occur. When this happens just deselect what you had selected and then click on the character in your scene that has the animator attached.

Now clear the messages in the console and go into game mode. The warning messages should be gone and you should see the animator panel updating in real-time. Now why it gets “disconnected” in the first place, that I don’t know…

You need AnimatorCtrl.scripts

As I mentioned in the original post I have no character in the scene, it’s loaded at runtime from an assetbundle so I’m unable to do as you described. There is nothing selected in the scene prior to runtime.

These warnings appear any time I try to set a value in the animator engine, they are definitely show stopper errors (Or indicative of another problem) as I am entirely unable to use the animation system.

Could you elaborate? I don’t see a class named AnimatorCtrl or AnimatorControl or any mention of it in the documentation.
Edit: I found the AnimatorController class, but that’s in UnityEditorInternal and doesn’t appear very relevant to my issue.

There is an animation script of course, that is the one causing these warnings

void Update()
	{
		if (!MyAnimator)
			return;
                ...
		float h = Input.GetAxis("Horizontal");
		float v = Input.GetAxis("Vertical");
		float r = Input.GetAxis("Rotate");
		MyAnimator.SetFloat("Strafe", h, DirectionDampTime, Time.deltaTime);
		MyAnimator.SetFloat("Movement", v, DirectionDampTime, Time.deltaTime);
		MyAnimator.SetFloat("Rotate", r, DirectionDampTime, Time.deltaTime);	
                ...
	}

Each time SetFloat is called a warning is printed to the console saying the Animator has not been initialized.

Can’t seem to work around this issue, any Unity developers have some input here?

Character works fine in a test prior to export, but once it’s loaded from an assetbundle it stays stuck in T pose and won’t animate at all, everything in the inspector looks identical.

I have had the same problem. Do you solve the problem?

Nope, we’ve tried multiple configurations of script/character controller/animator and still no luck, Mecanim seems to be unusable with asset bundles at this point.

It seems like a nice system but it’s far too opaque and there’s a huge lack of documentation.

Following the tutorial at http://video.unity3d.com/video/6428539/unity-4-using-mecanim I have the exact same issue. It didn’t happen until I tried to restart Unity and now I can’t access anything related to my Animator component. My code and scene match the video’s 100% but no matter what I try they are just inaccessible. Pretty bummed out about this considering the amount of time I spent trying to narrow down my mistake just to find out there’s nothing I can apparently do about it. A Unity Developer shining some light on the subject would be highly appreciated.

This probably is a bug, I myself lost lots of time trying to workaround it, did you file bug report already?

Hi Patrick,

can you submit a bug with your assetbundle also reply to this thread with your case number so we can track it down more easily.

Usually when you get a ‘Animator has not been initialized.’ it either if

  1. you don’t have an Avatar attached to your Game Object. you can call Animator.avatar to see if it not null.
  2. you don have an Avatar but it not valid. you can call Animator.avatar.isValid to see if it valid.
  3. the controller is not valid, in that case we will need the assetbundle to find out why.

Sonny

The bug has been reported, and the case number is 502380.

Avatar is not null, and isValid returns true.

As for the possibility of the controller not being valid I’ll await your input, but the controller in the asset bundle works fine in the test scene it was exported from.

Hi Patrick,

We got some issue with asset bundle and mecanim controller, object are not correctly bundled. There is nothing you can do right now until it fix. We will try to fix this ASAP.

Sonny

Hi Sonny,

Any chance we can get a rough ETA on this?

I need to know if we should wait for a fix or go back to the legacy animation system for the time being.

Thanks

No ETA at the moment but it is high in our priority

Is there a workaround for this? I’m starting to try switch over from using temp sprites to mecanim, and… well, I’m getting this warning. Pretty much dead in the water.

I am not using an asset bundle

If not using an asset bundle everything works fine here.

The problem only appears for us if we try to load the character at runtime from an assetbundle.

Calling Resources.Load() on a prefab with the character that is already contained within the client works perfectly.

Any updates on this?

The only thing I can tell you is asset bundle is really high in our priority list.

still nothing? I would really appreciate this being resolved.

This is fixed in 4.1