Creating Double Jump!

addam davis
3 min readDec 23, 2021

Objective: Create a double jump function for the player to purchase from the shop.

One of the options we created in the shop were the “Boots of Flight.” In this tutorial we are going to create these “Boots” and give the double jump function to the player.

We are going to start by opening the player’s script. We need two bools for when the player’s double jump ability is active, and when they can double jump.

Serialize these for testing in the editor

We need a method to activate the double jump.

When the ability is active the player can double jump. Now, navigate to our code that handles how the player can jump.

This code is called when the player pressed the B button when grounded. Next, we need an input check for the B button if the can double jump is true.

When this is called, we want to turn the can double jump bool to false so the player can’t jump anymore until after they land. We need to add to the rigidbody as we have done before.

Now we want to repeat the jump animation. To do this we head over to the animator view on Unity and transition from the AnyState to our jump animation.

Create a trigger parameter called “DoubleJump” and add this condition to the transition. Set the has exit time to false and transition duration to 0.

We now need to call this parameter by opening the player animation script. we need a method for the player to call to trigger this parameter.

The player needs to call this when they double jump.

Now you can test your player’s double jump in the editor by activating the double jump in the editor.

Finish this off by connecting this to the shop. When the player buys the Boots of Flight, it will call the player’s double jump active method.

Now your player can activate double jump if they have enough gems. Don’t be afraid to experiment with your powerups, and I’ll see you in the next tutorial!