Animator is not playing an AnimatorController (2020.1.10f1)

I searched for this issue online and found some responses, but none of the solutions presented worked for me. Apologies if this is not the correct place to ask for help. I’m ~90% sure this was working as written in a previous version.

When I attempt to pick up an item, the console error says:
[timestamp]Animator is not playing an Animator Controller
UnityEngine.Animator:SetTrigger(String)

Animator references in PickupItems.cs (which is on the Player Camera object, see below):
```csharp
**public Animator animArms;

private void PickUp()
{
// code to re-position item to hand - this works

  Debug.Log("currentItem.name: " + currentItem.name); // Correct item name

  switch (currentItem.name)
  {
     case "rifle":
      animArms.SetTrigger("equipRifle");            // ERROR
      animArms.SetBool("rifleEquipped", true);  // ERROR
       break;
     default:
       Debug.Log("Picked up: " + currentItem.name); // test
       break;
  } // switch(currentItem.name)

} // PickUp()**
```

Inspector: Arms object to be animated

The Player Camera object in the inspector:

Any help is greatly appreciated. Thank you in advance!

I think this comes from the GameObject upon which you’re animating not being active.

https://answers.unity.com/questions/1337226/animator-is-not-playing-an-animatorcontroller.html

If I do this:

case "rifle":
          if(animArms.gameObject.activeSelf) {
             animArms.SetTrigger("equipRifle");
             animArms.SetBool("rifleEquipped", true);
           }
           break;

I get the “Animator is not playing an AnimatorController” error as soon as the scene loads, instead of when I try to pick up the rifle object.

Same thing happens if I try:
if (animArms != null && animArms.isActiveAndEnabled)
or
if (animArms != null)

It does occur to me that I have replaced the arms .fbx object several times as I’ve added animations … do I need to create a new animation controller each time?

Are you inadvertently starting the animation on the prefab object rather than the instantiated object?

1 Like

How do I verify that?

When I create the .fbx in Blender, the file is saved directly into a subdirectory (not Prefabs) of my Unity Assets directory and then gets dragged into the hierarchy. At no point does it ask me to turn it into a Prefab. Does it get turned into a Prefab automatically?

I appreciate the time you’re taking to help me.

The distinction is “does it live in the scene now?” or not.

When I say “prefab” what I mean is “not-in-the-scene asset,” which could be your FBX, or could be your prefab (if you have one).

The key is in Unity you typically either place the object in the scene, OR you drag a reference to the asset into your script, and your script uses Instantiate() to make a fresh copy (which Instantiate returns a reference to).

If you are trying to animate the reference to the asset (as opposed to animating the instantiated thing in the scene), that won’t work and will produce the above error. Instead, animate the copy that you instantiated.

The Hierarchy tab shows everything in the scene when it starts. I am not adding anything programmatically.

Then before doing the offending animator call, print the name of the GameObject and the .activeSelf property and prove to yourself which GameObject it is on, and that it is active.