Adding a double jump — Physics based character controller using new Unity Input system.

In this quick article, following on from my previous one, I will go over how to add a double jump mechanic to your game.

The first step is to create a bool to check if the player has double jumped.

In our script we will change the jumping function. We will remove the “if grounded” check first. We then will exit the function (using return) if the player has already double jumped. We then check if the player is currently jumping and if so we set the “has double jumped” bool to true. We then apply our jump height to velocity as normal.

The next step is to reset our “jumping” and “has double jumped” bools. We do this in our movement script when we check our y velocity.

Next we can test the function.

That's all for now.

--

--

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
Luke Duckett

Luke Duckett

Unity developer with a love of learning all things programming.