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.

--

--

--

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

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

Recommended from Medium

Quiz | Computer Fundamentals | Set 24

3 Ways We Use Redis to Make Gaming Awesome

Making my homepage score 95+ on PageSpeed Insights

Code Smell 137 — Inheritance Tree Too Deep

4 Recommendations of Arduino Types for Beginners

Uno R3 DIP Arduino

Python — Try & Except Statements

Is GoLang really fast?

Why I Converted an AWS SAM Template to Serverless (And Maybe You Should Too)

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.

More from Medium

Pushing Objects in Unity

Fitting Unity in the Graphics Pipeline

Making a 2.5D Character Controller in Unity Part 1

Gamedev Log: “Slash’n’crack” #5 (Unity/C#)