Double Jump in Unity

Objective: allow the player to jump twice before touching the floor again.

We have ready the player jump, but now we want to give the player the chance to jump again before touching the floor.

In the player script I created a new bool variable called _doubleJump, then in the update method when we check if the player is grounded, if it is true we set the value of the bool to true and if it is false we check for the space key and if the _doubleJumpp variable is true, in that case we add the jump height to the vector and set the value of _doubleJump to false to avoid to jump again.

And that’s it!!!! Now the player can jump twice.

--

--

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
Rusben Guzman

Rusben Guzman

A Software Engineer passionate about game dev and interactive products with Unity. I consider video games to be the artistic expression of programming.