unity mobile touch follow code example
Example: unity mobile touch input
// 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;
}
}
}