Search Unity

how to check the current transition in the animator tree

Discussion in 'Animation' started by godaboveme92, Jul 2, 2022.

  1. godaboveme92

    godaboveme92

    Joined:
    May 15, 2022
    Posts:
    12
    hey guys, I'm trying to check if I'm at the last motion in the animator tree of an object but I don't understand how to write the code right..
    this is the code:

    Code (CSharp):
    1.         if(Input.GetKeyDown(KeyCode.Space))
    2.         {
    3.             anim.SetTrigger("NextText");
    4.         }
    5.         else if(Input.GetKeyDown(KeyCode.Space) && anim.GetCurrentAnimatorStateInfo(0).IsName("ForthBoxLoop"))
    6.         {
    7.             Debug.Log("true?");
    8.             anim.SetTrigger("ExitText");
    9.         }
    and here is an image for understanding better.
    the text changes and gets to the final box in the animator tree but the second else if statement won't work, it's written wrong and i can't figure out how to fix it.