Platformer Enhancements - Double Jump

Favourite 84 favourites
Tutorial written by BluePhazeOriginally published on 4th, February 2013 - 4 revisions


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.

Unlock your full gamedev potential

Upgrade to the Personal Edition of Construct 2, it has way more features and won't holding back from making money and using your full creativity like the free edition does. It's a one off payment and all Construct 2 editor updates are free for life!

View deals

Plus, it's got a lot of additional features that will help you save time and make more impressive games!

Congratulations on finishing this tutorial!

Did you learn a lot from it? Share it now with your friends!

Comments

2
Neutronmax 2,499 rep

Awesome, lot's of details and well explained. Tried and worked very well. Thanks!

Thursday, February 07, 2013 at 3:33:11 PM
1
BluePhaze 14.7k rep

Thanks @Neutronmax, Glad it was of use for you! Currently I am in the process of trying to figure out what I want to do a tutorial on next...

Friday, February 08, 2013 at 6:08:28 AM
1
sman118 7,820 rep

Great tutorial. Thanks for including all of the pictures and being so descriptive. If I can make a suggestion for a future tutorial, maybe a lifting and carrying mechanic like in Super Mario Bros 2. I've been trying to do it with having objects stick to an image point, but am always looking for an alternative.

Friday, February 08, 2013 at 5:02:25 PM
1
BluePhaze 14.7k rep

@sman118 I will look into it and see if I can come up with an efficient way to do it. Image points are probably going to be a big part of it though as they are one of the only objects that let us define a spot on a sprite for interaction.

Thanks for the great feedback!

Tuesday, February 12, 2013 at 5:38:05 PM
1
Solano 2,252 rep

hi, thanks for the great tutorial u did there!
helped a lot!
but i cant get this working with a gamepad...
i did all the stuff up there but instead the keyboard action i used my gamepad.
every movement works with the gamepad except the double jump :/
any idea?

Monday, March 04, 2013 at 2:46:03 PM
1
BluePhaze 14.7k rep

if you post a capx I can take a look

Wednesday, March 06, 2013 at 7:27:24 AM
2
orangemicro 3,429 rep

When using a WASD control style, I don't understand why when I change the event of
"keyboard: On up arrow pressed" to "keyboard: On W pressed" it does not seem to want to jump at all.

I feel like logically you should be able to switch out the two without any problems. Do I have to deactivate the defaulted up arrow as jump, if so, I don't know how to do that. Could someone please help me.

Thanks in advanced.

Monday, March 25, 2013 at 8:02:13 PM
1
LiquidProQuo 2,084 rep

Super useful. Thanks!

Tuesday, March 26, 2013 at 10:53:58 PM
1
qu0y 3,151 rep

Hi I am using release 123.2 and I can't find the keyboard object to insert, I know I saw it on previous versions, what happened and how can I make it work around? cheers

Sunday, April 14, 2013 at 3:45:21 PM
3
BluePhaze 14.7k rep

Hey all, just answering some of the questions here:

@orangemicro You just need to make sure you have the keyboard object added and put in the event for Key Pressed W Simulate Platform Jump. If you want to disable the default controls then select your object that has the platform behavior in the layout , and you should see it's properties in the properties pallet to the left. There you can disable the default controls.

@LiquidProQuo Thanks!

@qu0y Double click on the background of your layout the same way you add sprites and you will see the keyboard object. If you don't see it, it is because you have already added it, and it will then be on the right hand side in the objects folder. Also you may want to update to build 125 as it fixes some bugs of previous builds.

Thanks again all for the comments!

Tuesday, April 16, 2013 at 7:56:29 AM
1
BluePhaze 14.7k rep

@Solano Most likely you need to have either a sub event or two events for the jump button being pressed, one if they are on the ground and another if they are already in the air (not on floor expression).

Tuesday, April 16, 2013 at 7:58:29 AM
1
fassFlash 4,377 rep

Yeah, implementing that Space Jump from Metroid

Friday, May 03, 2013 at 7:04:22 AM
1
Vicilius 1,519 rep

I'm just repeating what was already told, but thanks a lot for this great, nice and clear tutorial!

Tuesday, June 04, 2013 at 12:38:00 PM
1
Jijiji 3,656 rep

Very detailed tutorial: great job!

Thursday, September 12, 2013 at 7:25:46 PM
1
almostnot 734 rep

This tutorial was absolutely awesome. Totally clear about how the logic works but also great for new users of Construct 2 as well.

Thanks so much. Double jump is now in my game. Onto wall jump!

Wednesday, December 11, 2013 at 8:05:13 AM

Leave a comment

Everyone is welcome to leave their thoughts! Register a new account or login.