Search Unity

Question Issue with animations not playing

Discussion in 'Animation' started by Kalkans, Sep 10, 2021.

  1. Kalkans

    Kalkans

    Joined:
    Aug 16, 2017
    Posts:
    2
    Greetings, Im having issues with my animations. The if conditions are met because I can see debug.logs on console. But for some reason my animations are not playing. I have tried some things but I could not find any solutions.
     

    Attached Files:

    • a1.PNG
      a1.PNG
      File size:
      27.7 KB
      Views:
      279
    • a2.PNG
      a2.PNG
      File size:
      10.2 KB
      Views:
      285
  2. Unrighteouss

    Unrighteouss

    Joined:
    Apr 24, 2018
    Posts:
    599
    It's difficult to see from your screenshots, but if you're running the
    PlayTargetAnimation()
    method more than once, the animation is going to freeze because you're using
    Animator.CrossFade()
    .

    If that's the issue, then this should probably work:
    Code (CSharp):
    1.     public void PlayTargetAnimation(string targetAnimation, bool isInteracting)
    2.     {
    3.         animator.SetBool("isInteracting", isInteracting);
    4.    
    5.         if (!animator.GetCurrentAnimatorStateInfo(0).IsName(targetAnimation) && !animator.GetNextAnimatorStateInfo(0).IsName(targetAnimation))
    6.         {
    7.             animator.CrossFade(targetAnimation, 0.2f);
    8.         }
    9.     }
    This checks that you're not already in or moving to a state before crossfading. I think the reason is freezes is that you start a transition while in a transition or something. Honestly, I'm not entirely sure how it even works, but this should fix it.
     
    Last edited: Sep 10, 2021
  3. Kalkans

    Kalkans

    Joined:
    Aug 16, 2017
    Posts:
    2
    Thank you for your reply, unfortunately this did not solve it. But I found that if I remove my landing animation (turn it to idle anim.) my character does the falling animation. Still no landing animation tho, If I were to add it my character freezes again