Question by 
               Rubenazo1999 · Jun 01, 2019 at 11:58 PM · 
                movementplayertouchinput.touch  
              
 
              Help with moving the player with Input.touches
Hello!
I am trying to move the player via touches. When I touch the designated place the player moves, but when I stop touching the player keeps moving, I don't know why. Please tell me what I am doing wrong, no need to write any code, but I need to know what is wrong with my code.
     void MovementHandler()
     {
         //Activates touch controls
         if(Input.touchCount > 0)
         {
             foreach(Touch touch in Input.touches)
             {
                 Vector2 mouseRelativePosition = new Vector2(Input.mousePosition.x / Screen.width, Input.mousePosition.y / Screen.height);
                 float mouseX = mouseRelativePosition.x;
                 float mouseY = mouseRelativePosition.y;
 
                 if (mouseX < 0.2f && mouseY < 0.5f)
                 {
                     rb.velocity = new Vector2(-speed, rb.velocity.y);
                 }
                 else if (mouseX < 0.2f && mouseY > 0.5f)
                 {
                     rb.velocity = new Vector2(speed, rb.velocity.y);
                 }
                 else if (mouseX > 0.8f)
                 {
                     JumpHandler();
                 }
                 else
                 {
                     rb.velocity = new Vector2(0, rb.velocity.y);
                 }
             }
         }
     }
 
 
              
               Comment
              
 
               
              Your answer
 
             Follow this Question
Related Questions
Character movement 0 Answers
Make character face movement direction 0 Answers
How do I make my player jump? 1 Answer
How to insert and offset on movement in the direction of he object is facing? 0 Answers
How touch works 1 Answer