Animation won't stop (Solved)
So I have a script were if the Player presses and holds Q or E the player Rotates but when I release Q or E it does not stop, and go back to idle. If I press Q and then E it changes to different rotates, but if I just press Q or just press E it stays playing those animations.
if (Input.GetKey(KeyCode.Q)) { float rotationQ = Input.GetAxis("HorizontalQE") turnSpeed; rotationQ = Time.deltaTime; transform.Rotate(0, rotationQ, 0);
         if (isIdle == true)
         {
             anim.SetBool("isTurnLeft", true);
             anim.SetBool("isTurnRight", false);
             isIdle = false;
         }
         else {
             anim.SetBool("isTurnLeft", false);
             isIdle = true;
         }
         if (Input.GetKeyUp(KeyCode.Q))
             isTurnLeft = false;
         }
         else if (Input.GetKey(KeyCode.E))
         {
         float rotationQ = Input.GetAxis("HorizontalQE") * turnSpeed;
         rotationQ *= Time.deltaTime;
         transform.Rotate(0, rotationQ, 0);
         if (isIdle == true)
         {
             anim.SetBool("isTurnRight", true);
             anim.SetBool("isTurnLeft", false);
             isIdle = false;
         }
         else {
             anim.SetBool("isTurnRight", false);
             isIdle = true;
         }
         if (Input.GetKeyUp(KeyCode.E))
             isTurnLeft = false;
     }
Answer by M-Hanssen · May 18, 2016 at 01:19 PM
You are forgetting to reset the bools if there is no input:
 if (Input.GetKey(KeyCode.Q))
         {
             float rotationQ = Input.GetAxis("HorizontalQE") turnSpeed; rotationQ = Time.deltaTime; transform.Rotate(0, rotationQ, 0);
 
             if (isIdle == true)
             {
                 anim.SetBool("isTurnLeft", true);
                 anim.SetBool("isTurnRight", false);
                 isIdle = false;
             }
             else {
                 anim.SetBool("isTurnLeft", false);
                 isIdle = true;
             }
             if (Input.GetKeyUp(KeyCode.Q))
                 isTurnLeft = false;
         }
         else if (Input.GetKey(KeyCode.E))
         {
             float rotationQ = Input.GetAxis("HorizontalQE")*turnSpeed;
             rotationQ *= Time.deltaTime;
             transform.Rotate(0, rotationQ, 0);
             if (isIdle == true)
             {
                 anim.SetBool("isTurnRight", true);
                 anim.SetBool("isTurnLeft", false);
                 isIdle = false;
             }
             else
             {
                 anim.SetBool("isTurnRight", false);
                 isIdle = true;
             }
             if (Input.GetKeyUp(KeyCode.E))
                 isTurnLeft = false;
         }
         else
         {
             anim.SetBool("isTurnRight", false);
             anim.SetBool("isTurnLeft", false);
         }
Your answer
 
 
             Follow this Question
Related Questions
The referenced script on the behaviour is missing error help plz 2 Answers
I cant addet animation to script 1 Answer
I can't make transition from actual animation to previous one 1 Answer
How can I change GameObject's texture? 1 Answer
Exporting Maya Animation of player with ball to unity ? 0 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                