2.5D Platformer — #3 Double Jump Ability

Objective: Give the character the ability to double jump

In the last article, 2.5D Platformer — #2 Horizontal Movement, we left off with a character that can move left and right with gravity working against it. In this article, we will focus on giving the character the ability to jump and double-jump onto platforms.

Jumping involves overcoming the gravity for a short time before gravity pulls the character back down and it also must preserve the velocity along the horizontal direction.

We first need to create a variable to store the jump height

In the Update method, we want to make sure that the player can only jump when they are touching the ground. Lucky for us, the Character Controller just happens to have a flag that does this check.

So our basic rule goes, if the player is touching the ground and has pressed the Jump button then we want to apply a y-direction change to work opposite to gravity.

Having the ground check-in place ensures that the player doesn’t spam the jump button and in this case, can only jump once. Let’s now implement double jump so we can help the player reach higher platforms.

To do this we need to change the rules to only be able to jump when we are in the air (no grounded) and that we can only do an air jump once.

We need a variable to track if we can double

We have identified that we can double jump once we are in the air, so that is the best place to set it to true.

In the Update method we can now check if the Jump button was pressed while we are in the air for the double jump

Our player can now reach higher, hard to reach platforms with their new ability, the double jump.

If you enjoyed reading this article give me a Clap, also if you would like to see more, “Follow” me, so you may be notified of future releases. You may also send me a message if you need any further help.

Do you have a project in mind and need help getting it started, reach out to me

A Data & Analytics Consultant who is expanding into developing experiences in XR, Enterprise and Gaming space using Unity www.jeannoelseneque.com