Mobile device input

Hello,

i created a game and everything works in the unity editor and on PC but the mobile version works incorrectly because of the input.

The player jumps multiple times on 1 touch but i want to let the play jump only one time at every touch.

		if (Input.touchCount > 0) {  // 1 touch = 1 and not higher ? 
			didFlap = true;
			audioWoosh.Play ();


		}

If this bit of code is in the Update function/method of the scripting, then you will get a true evaluation every frame during the execution of this code. This is because you haven’t constrained the logic to how/when it was touched, only if there is a touch during the frame.

Using Input.touches to check to see if it’s the first touch and it ‘began’ would be a good way of isolating the execution.

You may also only want to check for a single touch.

if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Began) 
{
	didFlap = true;
	audioWoosh.Play ();
}

Input.GetTouch

Touch Phases

//FlappyBirds?
private int touchesSoFar=0;
Update
{
if (Input.touchCount> touchesSoFar) {
touchesSoFar++;
didFlap = true;
audioWoosh.Play ();
}
}