How to add Double Jump to your Game
Aug 11, 2021
For this blog, we will have as a reference the previous one, in which we explained how to jump using the jumpHeight
value
So far, the player can jump only if it isGrounded
To let it jump again, we need to create a new bool doubleJumpEnabled
. It will become true after pressing the space key
Later, if it’s not grounded, the else
statement will check if doubleJumpEnabled
is true. if so, we press space key again to add the jumpHeight
value again to yVelocity
. This way the player will “jump” again
After that, doubleJumpEnabled
will be set to false, for avoiding a new jump in the air