Search Unity

After saving the scene: Animator is not playing an AnimatorController

Discussion in 'Animation' started by Zwer99, May 23, 2018.

  1. Zwer99

    Zwer99

    Joined:
    Oct 24, 2013
    Posts:
    24
    Hello!

    I've written an editor-script which reads the parameters of the Animator. I'm also doing some null-checks and it works fine:

    Code (CSharp):
    1. if (animator != null && animator.gameObject.activeSelf && animator.runtimeAnimatorController != null)
    2.     parameters = animator.parameters;
    But after saving the scene I'm getting the following error:

    Code (CSharp):
    1. Animator is not playing an AnimatorController
    2. UnityEngine.Animator:get_parameters()
    The program passes the null-checks, but says that there's no AnimatorController playing in line 2 of the snipped above. The only way to make it work again is to remove the AnimatorController in the inspector and reassign it. What can I do? Why is that only after saving the scene?

    Thank you very much :)
     
    Last edited: May 23, 2018
  2. Zwer99

    Zwer99

    Joined:
    Oct 24, 2013
    Posts:
    24
    No ideas?
     
  3. Zwer99

    Zwer99

    Joined:
    Oct 24, 2013
    Posts:
    24
    Really no ideas ^^?
    Sorry for pushing, but I need to fix this.
    Either this is a bug or I need to check against another condition?

    Thanks :)
     
  4. Veetha

    Veetha

    Joined:
    Jun 27, 2017
    Posts:
    6
    Did you find a solution? I've ran into same problem... :(
     
  5. Veetha

    Veetha

    Joined:
    Jun 27, 2017
    Posts:
    6
    For anyone who have ran into similar problem and known solutions didn't work for him. You can work-around by turning animation controller off and on like this:

    Code (CSharp):
    1. if (GetComponent<Animator>().GetCurrentAnimatorStateInfo(0).length == 0 )
    2.         {        
    3.             print("Warning: animation state info length = 0, restarting animator...");
    4.  
    5.             /* workaround for recurring error message "Animator is not playing an AnimatorController" which emerged after every save of project and prevented further operating the script until animation controller weren't removed and reset.
    6.              * This is merely automation of described solution. */
    7.             GetComponent<Animator>().enabled = false;
    8.             GetComponent<Animator>().enabled = true;
    9.             GetComponent<Animator>().gameObject.SetActive(true);  // this is actually  not needed in this case
    10.        
    11.         }
     
  6. learner_CL

    learner_CL

    Joined:
    Dec 23, 2016
    Posts:
    6
    I ran into the same problem at Unity 2018.4.1f1,The last line" GetComponent<Animator>().gameObject.SetActive(true); " is only line I needed in this case
     
  7. wpetillo

    wpetillo

    Joined:
    May 23, 2017
    Posts:
    24
    Running Unity 2019.4.0f1. Turning the controller off and on causes Unity to crash. This works though:

    Code (CSharp):
    1.  
    2. if (headAnimator.GetCurrentAnimatorStateInfo(0).length == 0)
    3.     headAnimator.Rebind();
    4.  
     
    Last edited: Jun 12, 2020
    Munchy2007 and Xaurrien like this.
  8. mikolajkubiak

    mikolajkubiak

    Joined:
    Oct 21, 2020
    Posts:
    2
    I've run into it as well, seems like gameobject with animator has to be active in the scene, no messege then.
     
  9. Munchy2007

    Munchy2007

    Joined:
    Jun 16, 2013
    Posts:
    1,735
    Thanks, this works for me using Unity 2021.1.22f1