Search Unity

Animator variable gets empty when I play the game

Discussion in 'Animation' started by Alvar0x, Apr 21, 2020.

  1. Alvar0x

    Alvar0x

    Joined:
    Jan 18, 2020
    Posts:
    1


    When I play the button, the Animator space gets empty... Does someone know why does it happen?
     
  2. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,570
    Something (probably in that script) is either setting that field to null or destroying the Animator.
     
  3. Asumacat

    Asumacat

    Joined:
    Sep 30, 2020
    Posts:
    2
    Having the same issue sadly.
    did you find a fix?
     
  4. Erenquin

    Erenquin

    Joined:
    Apr 9, 2018
    Posts:
    164
    I was wondering why my animator was null at run time thend found out your post, checked, and indeed that's exactly what is happening the animator is set to nothing at run time.

    In short, I'm in the same boat.

    Well 2 seconds later I found out ... As I moved my components around found out I had a trailing "animator = GetComponent<Animator>();" in the "start" of the script.
     
  5. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,570
    Unity doesn't just clear your references for no reason.

    Something in your code is setting it.