Search Unity

Animator transition parameter not working.

Discussion in 'Animation' started by tetingthis, Sep 13, 2018.

  1. tetingthis

    tetingthis

    Joined:
    Apr 20, 2018
    Posts:
    4
    The else part works but the first one doesn't.





    In my Animation Controller the bool is changing but It isn't transitioning.

    Code (CSharp):
    1.     public bool Aiming_down_sights = false;
    2.     public GameObject Switching;
    3.  
    4.     public void Aim_down_sights()
    5.     {
    6.         if (Aiming_down_sights == true)
    7.         {
    8.             Aiming_down_sights = false;
    9.             Switching.GetComponent<Character_Switch> ().Current_Character.GetComponent<Animator> ().SetBool("AIM", false);
    10.         }
    11.         else
    12.             Aiming_down_sights = true;
    13.         Switching.GetComponent<Character_Switch> ().Current_Character.GetComponent<Animator> ().SetBool("AIM", true);
    14.     }
     
    cloud_2017 likes this.
  2. Raidenwins

    Raidenwins

    Joined:
    Dec 18, 2012
    Posts:
    132
    Is method Aim_down_sights() being called from the Update method? If so, it looks like parameter "AIM" is constantly being set to False and then True, then False again True again, and so forth. Also, in your ELSE clause, did you mean to include the statement for setting "AIM" to True? Because if you did, you should open brackets after the ELSE and close them after setting the parameter to True.
     
    tetingthis likes this.
  3. tetingthis

    tetingthis

    Joined:
    Apr 20, 2018
    Posts:
    4
    Thank you the else was indeed causing it.