Search Unity

  1. Unity 2018.3 is now released.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. We've updated our Terms of Service. Please read our blog post from Unity CTO and Co-Founder Joachim Ante here
    Dismiss Notice
  4. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  5. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice

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.     }
     
  2. Raidenwins

    Raidenwins

    Joined:
    Dec 18, 2012
    Posts:
    102
    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.