Platformer Enhancements - Double Jump

7

Index

Stats

14,546 visits, 38,598 views

Tools

Translations

This tutorial hasn't been translated.

License

This tutorial is licensed under CC BY 4.0. Please refer to the license text if you wish to reuse, share or remix the content contained within this tutorial.

Published on 4 Feb, 2013. Last updated 19 Feb, 2019

27. Go ahead and test your project. Try to double jump more than once. Notice that once we land from our first double jump that you can no longer do the double jump... This is because we need to do one more thing. Once the player lands, we need to set the variable (jumpPhase) back to 0. That way the next time we jump, it will work again. Action: Add a new event to our event sheet. This time add an event for Player is On Floor, and then set the variable jumpPhase back to 0. You should be familiar enough now to do this on your own, but if you need a hint your event sheet should now look like this:

28. Now go ahead and test your project again. Now the double jump is working the way I want it to. You now have a functional double jump. You can tweak any of the settings to make it work in a way that more closely matches the needs of your game. If you want to tweak it further, I will add another option to our double jump in the next few steps.

29. One thing you may have noticed about the double jump is that it is still enabled even if the player walks off a ledge. This means that they can walk off a cliff or other platform in your game and do a double jump from mid air even though they did not initially jump. While this may be fine for some games, it may also lead to unintended shortcuts and exploits depending on your level design. So now let's look at how to disable double jumping for player who have just walked off a ledge.

30. For this we are going to change our logic to test if jumpPhase is equal to 1 instead of less than 1. We will also make it so that when a player does their initial jump, we set jumpPhase to 1. This means that when they jump we set it to 1, and it then checks for that 1 value before it allows us to double jump. We will also update our double jump so that in the last step where it used to set jumpPhase to 1 (which we are now doing as soon as they jump), we will add 1 to jumpPhase instead. This means that when they double jump, it will add 1 to jumpPhase again making the value of the variable 2. This will keep them from triple jumping, etc... because we test for 1 first, not 2. While this may sound like a lot, it is actually pretty simple once you see it on the event sheet. It should now look like this:

Summary

You should now have a good idea how to implement a double jump and also how to tweak it to fit your needs. If you want a triple, quadrupal jump, etc... you can simply update the events to check if the variable is equal to a higher number instead of just 1. You set it to the number you want and that is the number of times they will be able to jump after the initial jump.

If you want more ideas on how to implement it as a powerup, or other things you can do with the type of events we have worked with today, feel free to check out my wall jumping tutorial which also covers how to make the jump events powerUp based. That way if you only want the player to be able to use the special jumping moves when they have collected a powerUp, you can do that as well. Platformer Enhancements - Wall Jumping

Thanks for taking the time to walk through this tutorial, as always if you have any suggestions or feedback, please feel free to let me know. And again, if you found this tutoiral helpful, please use the voting buttons to make it easier for others to find it as well.

  • 1 Comments

  • Order by
Want to leave a comment? Login or Register an account!
  • This is amazing, Thank you! This may help me with triggering the jump sound better. Right now my player can press jump and while in the air can continue to press jump and the sound will trigger. If I can trigger it on jump phase that would alleviate my issues I believe!