I am making an audio only endless runner where obstacles come at the player while emitting a sound, like sonar. However, the way the code works now the player can infinitely jump (not vertically but along the path) by constantly clicking or hitting the space bar.
I am trying to find a way to restrict the players jumps to something like 3 and then resetting it after they have passed the obstacle.
Thank you for your help.
if (Input.GetKeyDown(KeyCode.Space) || Input.GetMouseButtonDown(0)){
if (grounded) {
myRigidBody.velocity = new Vector2 (myRigidBody.velocity.x, jumpForce);
}