Problem with swipe and player jump

Good night, all right? I’m programming a mobile game and I’m the problem: I have a code to check if the player makes the “swipe” on the screen up to perform a leap of character. The code works correctly, however, the size of the leap varies according to swipe the size of the player did, how can I adjust so that, regardless of size, the jump is the same height (I set the AddForce)?

if(Input.GetTouch(0).phase == TouchPhase.Moved) {
	var posicaoDeltaTouch : Vector2 = Input.GetTouch(0).deltaPosition;

	if(posicaoDeltaTouch.y > 5 && posicaoDeltaTouch.x < 5 && posicaoDeltaTouch.x > -5 && jogador.GetComponent(ColisaoPlayer).naSuperficie == true) {
		jogador.GetComponent(Rigidbody).AddForce(0, 400, 0);

Thank you!

It’s probably being called several times. Place a debug.log() right where you make the character jump to check if this is indeed happening. If so, you’ll have to add another check so that players can’t jump twice with 1 swipe.

@Rostam24 I understand, but it turns out that there is already a variable “naSuperficie” that makes the player jump only when it is on the ground, that is, you can not make another jump while it is in the air. I do not understand what may be happening …