Search Unity

  1. Check out the Unite LA keynote for updates on the Visual Effect Editor, the FPS Sample, ECS, Unity for Film and more! Watch it now!
    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. Improved Prefab workflow (includes Nested Prefabs!), 2D isometric Tilemap and more! Get the 2018.3 Beta now.
    Dismiss Notice
  4. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  5. Want to see the most recent patch releases? Take a peek at the patch release page.
    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:
    100
    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.