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