Search Unity

How to change a bool after animation trigger is over?

Discussion in 'Animation' started by jleven22, Feb 5, 2020.

  1. jleven22

    jleven22

    Joined:
    Mar 26, 2019
    Posts:
    421
    I am having the player perform a dodge roll. Right now it dodges fine, but the isDodging bool does not turn off.

    I'm a bit new to triggers, so I could use the advice, thank you!

    Code (CSharp):
    1.             if (Input.GetKeyDown(KeyCode.Space))
    2.             {
    3.                 if (dashCoolCounter <= 0 && dashCounter <= 0)
    4.                 {
    5.                     isDodging = true;
    6.  
    7.                     AudioManager.instance.PlaySFX(dashSound);
    8.  
    9.                     activeMoveSpeed = dashSpeed;
    10.                     dashCounter = dashLength;
    11.  
    12.                     anim.SetTrigger("dash");
    13.                  
    14.                     PlayerHealthController.instance.MakeInvincible(dashInvincibility);
    15.                 }
    16.                 else
    17.                 {
    18.                     isDodging = false;
    19.                 }
    20.  
    21.             }
     
  2. jleven22

    jleven22

    Joined:
    Mar 26, 2019
    Posts:
    421