atiyar
0
Q:

recognizing touch input unity

// its a simple jump on tap and while tap controller
// for a geometry dash like game
void MobileController(){
        // for the touch movement
        if (Input.touchCount > 0)
        {
	        theTouch = Input.GetTouch(0);

	        if ((theTouch.phase == TouchPhase.Began || theTouch.phase == TouchPhase.Stationary 
            || theTouch.phase == TouchPhase.Moved) && isGrounded)
        	{
	        	myRigidbody.AddForce(Vector3.up * (jumpPower * myRigidbody.mass * myRigidbody.gravityScale * 10.0f));
                myAudioPlayer.PlayOneShot(jump);
                isGrounded = false;
        	}
        }
    }
1
 if (Input.touchCount > 0) { }
-1

New to Communities?

Join the community