Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Moving animation takes action permanently

Discussion in 'Scripting' started by arda123, Mar 1, 2015.

  1. arda123

    arda123

    Joined:
    Mar 8, 2014
    Posts:
    4
    Code (CSharp):
    1. if (Input.GetAxisRaw ("Horizontal") != 0)
    2.       anim.SetBool ("Moving", true);
    3.  
    ;
    when the animation bool is true, it sets the animation permanently. It doesnt stop! i have no else if commandon my mind

    The question :

    How can i set the moving bool false (else doesnt work)

    Any code like this
    Code (CSharp):
    1.  
    2. if (Input.GetAxisRaw ("Horizontal") != 0)
    3. {
    4.       anim.SetBool ("Moving", true);
    5. }
    6. else if (Input.GetAxisRaw ("Horizontal")  = 0)
    7. {
    8.      anim.SetBool ("Moving", false);
    9. }
    10.  
    i am begginer in development (as a 13 year old guy) i would be pleased if you answer me



    TNX
    Arda Bulut (TUR)
     
  2. Juice-Tin

    Juice-Tin

    Joined:
    Jul 22, 2012
    Posts:
    242
    Code (CSharp):
    1. else if (Input.GetAxisRaw ("Horizontal")  == 0)
    There is always 2 things in an if statement.
    !=
    &&
    ||
    ==
    If you just use 1, you won't get an error but it just won't work.