Touch control swipe up to jump

This is probably extremely simple but bare with me i’m new to touch inputs. I’m creating a game for android devices where when the player swipes up the character jumps. Any insight on how to achieve this?

A simple script snippet for this would be:

void checkTouch(){
	for (int i = 0; i < Input.touchCount; i++) {

		Touch touch = Input.GetTouch (i);

		if (touch.phase == TouchPhase.Began) {
			startTouchPosition = touch.position.y;
		} else if (touch.phase == TouchPhase.Ended) {
			endTouchPosition = touch.position.y;
			if (endTouchPosition > startTouchPosition) {
				jump ();
			} 
		}
				
	}
}

Now you’d have to implement the “jump()” method to make your character jump.