Search Unity

Animator and Scripting problem

Discussion in 'Animation' started by Blenderik, Dec 8, 2019.

  1. Blenderik

    Blenderik

    Joined:
    May 14, 2013
    Posts:
    146
    I'm not new to Unity, but this is the first time I tried to really jump into character animation. There are some weird behaviours that I consider bugs, but maybe it was my fault:
    1. I have a layer for idle and smile. This works, but when I add a third layer no matter what animation I put in there it doesn't play.
    2. I found this problem many times, but no solution, so I'm hoping it's been fixed by now:
    If I want to play my blink clip using
    Code (CSharp):
    1. void blink()
    2. {
    3.      Animator myAnimator = GetComponent<Animator>();
    4.      myAnimator.Play("Blink"); // error layer = -1...
    5.      myAnimator.Play("Blink", 1) // I get the warning: Animator.GotoState: State could not be found
    6. }
    In both cases the animation does not play.
     
  2. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,570
    No idea about #1, but for #2 are you sure you have a state named "Blink" (capital B, with the exact same spelling)?
     
    Blenderik likes this.
  3. Blenderik

    Blenderik

    Joined:
    May 14, 2013
    Posts:
    146
    OK, that was a misunderstanding on my side. By dragging my animation clip into the Animator, it created a state
    "Armature|Blink". I did not understand that each clip gets attached to a state and was really wondering why it didn't say "Clip not found". Thank you for assuming the worst.
     
    Last edited: Dec 9, 2019
  4. Blenderik

    Blenderik

    Joined:
    May 14, 2013
    Posts:
    146
    As for the 1. Problem. I created a new FBX, since nothing was working any more, not even the entry animation. I was lucky I just started though, I'd hate let my Animator go down the tubes after I put work into them.