How to double jump in Unity

Daniel Kirwan
2 min readJul 20, 2021

Objective: Allow the player to have a double jump

In my previous article I went through the initial setup for the player to move and of course jump. Now, I will go through how to implement a double jump with the character controller I have implemented.

I first created a new bool called canDoubleJump. This will help with enabling the possibility for the player to double jump. You could of course link this to a player upgrade in a game but I am allowing the player to double jump from the beginning of the game.

If the player is on the ground and the player presses the jump button then the player is then moved up in the yAxis. I have added a new line that will now change the bool for doubleJump to true. This means that every time the player jumps off the ground, the bool will be turned true.

The else statement, will the be run if the player is not grounded and then if the player presses the space key again, then the another check is run. If the canDoubleJump bool is true, then the yVelocity variable is then added to itself and the jumpHeight. This gives it the double jump. Once the yVelocity is changed I then change the bool back to false, so that the player can not do additional jumps. The next step is to then change the yVelocity with the gravity.

And that is it for completing a double jump feature. Come back for me on the character controller set up.

--

--