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…
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.
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.
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.
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.
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.