"Animator is not playing an AnimatorController" UnityEngine.Animator:SetTrigger(String)

Trying the tutorial Recorded Video Session: Making A Flappy Bird Style Game - Unity Learn

When I run the game and the script does a setTrigger I get this error in the console “Animator is not playing an AnimatorController”

The games runs but I cannot understand how to make this error go away

I am using 5.6.0f3 and the demo video is using 5.5 so perhaps the instructions don’t match up or perhaps I’ve just done something wrong.

Any clues where to look or other info I could provide to help someone help me?

FYI there is a background animation too - and I’ve noticed that when this error occurs the bg animation stops.

Thanks

1 Like

Just for completeness (and others googling the problem):
This warning will be thrown, when the gameobject containing the animator is not active. To avoid the problem check for animator.gameObject.activeSelf.
Source

22 Likes

@Johannski
Thanks man. that was helpfull…

I’m just having the problem that GetCurrentAnimatorStateInfo isn’t working it says GetCurrentAnimatorStateInfo(Int32) And also this appeared: SetFloat(String, Single)

Am I right in thinking that this error actually isn’t that bad for the game? I have the same thing because the GameObject containing the animator is repeatedly being activated and deactivated. But everything seems to run just fine when the the object is active and playing the animation.

It a warning to let you know that you are trying to change something but the animator cannot carry out the operation because it disabled or it not playing any animation.

You are basically doing an operation that does nothing.
So the warning isn’t that bad for a game but you are actually using cpu cycle that will give no result.

3 Likes

This seems to happen any time you disable a game object with an animator on it. Even if no script is doing anything and no calls to setTrigger, it happens here until i re-enable the object. Which means I cant turn off an animator or it just constantly has this warning coming up. Any solution to that ?

1 Like

That could be a bug then, if nothing interact with the animator it shouldn’t throw a warning.

Please log a bug and we will investigate.

Sorry for the delay, though I cannot report the bug, the bug reporter has errors, it says “error occured whhile creating an archive error code file read failed”, im not attaching files.

my report would have been:

  1. What happened

If I disable a gameobject with an Animator on it, and it is completely off with no script using it. I still get “Animator is not playing an AnimatorController” as a warning in my game (repeatedly not just once), this creates a lot of output in my console, when really there should be none, because the objects aren’t even on anymore. The reason they turn on and off in my game is that when I leave a city theyre turned off, when I come back theyre turned back on.

  1. How we can reproduce it using the example you attached

Turn off any gameobject using an animator at run time

1 Like

Animator is not playing an AnimatorController. This error pops up whenever the setTrigger is called in a script. When this error happens the bird animation still works but the background animation stops moving.

yeh it seems to happen no matter if you call setTrigger or not.

1 Like

I’m still getting this warning two years later in 2021.3.21f1 when saving my scene.

I have an object with a component derived from Button and an Animator component. If I change any properties of any component on the GameObject and then save the scene, I get a burst of “Animator is not playing an AnimatorController” warnings that originate in the following line of code in Editor.OnInspectorGui() :

    // Have to comment out the following test because it results in a flood of "Animator is not playing
    // an AnimatorController" warnings for some bizarre reason when saving the project.
    //
    if( false == button.animator.parameters.Any( x => x.name == button.TransitionAnimations.NormalToSelected ) )

The GameObject is not disabled.
The Animator component is not disabled.
The Button component is not disabled.
Animator.runtimeAnimatorController is not null.

I am not attempting to play any animation or set or clear any triggers, I am simply attempting to query the parameters to see if a Trigger with a given name even exists.

I have not been able to find a workaround, other than simply not attempting to retrieve the list of parameters, which is obviously not a feasible workaround.

[EDITED TO ADD]
In my particular case, adding a check for EditorApplication.isUpdating resolved the issue during save, although I have now noticed that I still get the warning when I hit the Undo button after making any change in the scene.

@Johannski Thanks You saved me some time. :slight_smile:

But isn’t it possible to intentionally change a parameter on an inactive animator so that later when in becomes active it will have the correct parameters set ?

Thanks! That saved me from doing hours of research.

Still getting this today, @Johannski

And everything is active. I’m spawning a player prefab with Addressables and AssetReferenceGameObject.

1 Like

For me, activeSelf didn’t solve the issue activeInHierarchy did.

2 Likes

Sometimes the Animator can auto generate causing a lost path. This happened to me when deleting some files. I ended up with x2 Animators when only one is allowed. I deleted the auto generated Animator from Player has I had one set as a child.

I had this issue recently, and checking if animator.runtimeAnimatorController is null did the trick… :wink: