Search Unity

Setting up the animator

Discussion in 'Animation' started by Hapciupalit, Mar 21, 2018.

  1. Hapciupalit

    Hapciupalit

    Joined:
    Apr 24, 2015
    Posts:
    103
    I have a few NPC and I want all of them to use the same animator. In this animator I have a layer with Idle Animations, one with Walking Animation and so on.

    Like in this photo:


    Each layer looks like this :

    So let's say I want my NPC to stay somewhere around and playing Dizzy_Idle:
    I do this code:
    Code (CSharp):
    1. Animator anim;
    2.  
    3. void Start () {
    4.     anim = gameObject.GetComponent<Animator>();
    5.    
    6.     anim.SetInteger ("Idle", 2);
    7. }
    But when I hit play it seems like my animation is not playing till the end, but it repeat it's first part over and over again... And I can see the animation slider going from right to left over and over again without going till the end. It doesn't even reach half of the animation.
    Does any of you have a clue of what could cause this problem?
    Thank you
     
  2. theANMATOR2b

    theANMATOR2b

    Joined:
    Jul 12, 2014
    Posts:
    7,790
    Check has exit time. Does the animation complete now?

    Also - I don't see how the animation is returning to Idle - so that might be a variable that you could show so we have the full picture.
    Can you also show the inspector with Dizzy state selected if above has no change?