Platformer: Double Jump

Ryan McCoach
2 min readAug 24, 2021

Introduction

In this article we will cover that platformer staple of double jumping because sometimes we need to put on our Reebok Pumps to be able to get to a platform that is just out of reach.

Goal

  1. Jump once and while in the air be able to jump one additional time.

Double Jump

We will need to be able to track if we can double jump or not, so we are going to create a bool called canDoubleJump.

The first time the player jumps we will set this true

The player is no longer grounded, but we still want to be able to jump one more time when we press the space bar. In the else, we want to add another jump height to the existing yVelocity.

We are never the canDoubleJump bool to check if have already hit the space bar, so we can spam the button to get a Flappy Bird mechanic where you can stay in air for as long as you hit the jump button.

In the Else, when we press the space bar again to double jump, we want to see if we can using the bool canDoubleJump. If that is true, which we set to true the first time we jump, we will add another jumpHeight to the existing yVelocity. We cannot forgot to set canDoubleJump to false after this because if we do not you will still get the same Flappy Bird, flying behavior as before.

Double Jump Code

There is how you can create a double jump mechanic for your platformer. Cheers!

--

--