2.5D Platformer — #3 Double Jump Ability

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.

Implementing 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

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Web SSO for React + Servlet application with WSO2 Identity Server

Certy Network — Decentralized Storage for Degrees and Certificates

This Week in DevOps #3

Effortlessly Pulling Ethereum Block Data into Azure Machine Learning

Breaking the Coder Stereotype: My Storytelling Journey

Increase productivity with VSCode-Server

Fast and Accurate Incremental Feedback for Students’ Software Tests Using Selective Mutation…

Four subplots, each with four box plots showing operator subset cost, and line plots showing operator subset accuracy.

PullString now supports Slack Enterprise Grid, Slack’s new product for the world’s largest and most…

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Jean-Noel Seneque

Jean-Noel Seneque

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

More from Medium

Working with Unity’s 2D Tilemaps

Adding Post Processing to our Prototype

How to switch between Cinemachine cameras in Unity

My journey becoming a Unity game developer: 2.5D Infinite Runner-URP and Player’s 3D model added