Input.GetTouch being called every frame, how to stop this?

I’m working on a game like ZigZag, for mobile devices. What I want to do is if there is a touch on the right side of the screen, then jump, but if on the left side, then change direction (left or forward).

I have the jump one working fine, using a simple Raycast to check if the player is grounded, but when I touch the screen on the left to change direction, the code to change direction runs through every frame that the left side of the screen is touched, but I only want it to run through once, changing direction once, not once for every frame the finger is on the screen.

Here is my code:

//Touch controls
                if (Input.touchCount > 0)
                {
                    Touch touch = Input.GetTouch(0);
                    if (touch.position.x < Screen.width / 2)
                    {
                        if (dir == Vector3.forward)
                        {
                            MoveLeft();
                        }
                        else if (dir == Vector3.left)
                        {
                            MoveRight();
                        }
                        else if (dir == Vector3.zero)
                        {
                            StartMoving();
                        }
                    }
                    else if (touch.position.x > Screen.width / 2)
                    {
                        if (Physics.Raycast(downRay, out hit, rayHeight) && canJump)
                        {
                            Jump();
                        }
                    }
                }

I know this is because the code has been placed in the Update() function, but I don’t know how I can run through the code only when the left side of the screen is pressed and only once.

If any more code is required for my question to be answered, please don’t hesitate to ask.

Thanks

if (Input.touchCount > 0) {
   for(int i = 0; i < Input.touchCount; i++) {
      if(Input.GetTouch(i).phase == TouchPhase.Began) {
         Touch touch = Input.GetTouch(i);
         if (touch.position.x < Screen.width / 2) {
            if (dir == Vector3.forward) {
               MoveLeft();
            } else if (dir == Vector3.left) {
               MoveRight();
            } else if (dir == Vector3.zero)  {
               StartMoving();
            }
         } else if (touch.position.x > Screen.width / 2) {
            if (Physics.Raycast(downRay, out hit, rayHeight) && canJump) {
               Jump();
            }
         }
      }
   }
}

In this way you can also detect multiple touches. If you don’t want, just take out for ()

This works, thank you!