Hi, i’ve got some troubles with the jump for an Android app. Here is the code:
void Update()
{
if ((grounded || !doubleJump) && Input.touchCount == 1){
anim.SetBool ("Ground", false);
GetComponent<Rigidbody2D>().velocity = new Vector2(GetComponent<Rigidbody2D>().velocity.x ,0);
GetComponent<Rigidbody2D> ().AddForce (new Vector2 (0, jumpForce));
source.PlayOneShot(jumpSound,0.6f);
if (!doubleJump && !grounded)
{
doubleJump=true;
source.pitch = source.pitch + 0.5f;
}
}
}
The problem is this: when i touch the screen the character makes only double jump (i think because the update function check almost instantly if there is a touch on the screen, and there is not enough time to lift the finger from the screen and making a double jump because the function detect my previous touch as a new touch). Does anyone kows how to fix this issue?
Thanks!