Ask here your questions to get help using GDevelop.
By Shadowbonnie7
#70489 Hello, I would like to know how to control the height of a player's jumps. For example, if I hold down the jump button, the character will jump at it's maximum height. However, if I tap the jump button instead of hold it, the character does a tiny jump.

Many games I know have this feature. One notable example is "The End is Nigh" in which you can control the height of your jumps depending on how long the button is held down.

I found one similar topic of somebody asking this, but it wasn't very helpful to me.

Does anybody know how to accomplish this? Seeing how this was a feature in the original Super Mario Bros, I reckon that this shouldn't be too hard considering that even the NES was able to support that feature. Thanks in advance. :D
By Wendigo
#70494 I think this could be done this way:
- Disable the default controls and manually pick a "jump" key on the keyboard
- Check for the jump key pressed. While it is down increase the "Jump speed" of the platform character
- Check for the jump key released and simulate pressing the jump button.
- When the player is on the floor again set the "Jump speed" to the default value.

Instead of using the key released condition you could also start a timer when the button is pressed and make the player jump automatically after a certain time has passed so that the key needn't be released in order to jump.
By Shadowbonnie7
#70505 Thanks for your reply.
I tried your solution, but sadly, it doesn't make a difference. Maybe it is because I have multiple buttons that simulate jumping.
Code:
If one of these conditions is true: Simulate pressing Jump Key for Player
*Up key is pressed
*w key is pressed
*Space key is pressed

I have the default controls turned off. I also edited the code to make it so that only the up key jumps and tried it with your suggestion. Nothing changed.
Can you send me a code please? Thanks.
User avatar
By Jubeliuksen3
#70510 I made one example couple of years ago. It's not perfect (no timedelta used for example) but here it is:
https://jubeliuksen3.blogspot.com/2016/08/gdevelop-how-to-make-simple-jump.html?showComment=1473857400612&m=1

I think I would do it even more simply way nowadays. But I hope that helps you to figure something out :)
By Shadowbonnie7
#70514 Thanks for the example mate! It looks very helpful. I copied the code right from the image.
However, when I tested the project and made the player jump, almost hilariously, he took off like a rocket, got stuck on the ceiling, and wouldn't fall back down. XD
I couldn't download the example provided because GD5 can't run the file. Do I need to edit the player to make this work the way I want it to?
The players behavior is:
1500 Acceleration and Deceleration
Cannot grab ledges
Default controls off
1000 gravity
600 jump speed
600 max fall speed
150 max speed
60 slope max angle

Thanks in advance :D
By MattLB
#70515 I've not tried this, but maybe the way to approach it is to use the usual platformer behaviour to do the smallest jump and then separately check if the 'jump' key is still being pressed and if it is, apply an upwards force to the player character. To avoid the player becoming a rocket you would have to build in a limit to this, which might be with a timer check in the conditions of the event that prolongs the jump.
By Shadowbonnie7
#70549 Thank you for the suggestion, but could I please have a code or something?
I tried your suggestion out, and the jump pressure works, but when I hold the jump button, the player falls to the ground slower, but when I release the key, the player falls faster. Also, it plays the falling animation when the jump button is held. Can you please be more specific?
By MattLB
#70571 I've had a quick play and adding one new event and one action to the falling event seems to work:

longjump.png
longjump.png (24.11 KiB) Viewed 316 times


This is a modification of the platformer game that comes with GDevelop, so you'll have to play with the numbers to suit your game.
By Shadowbonnie7
#70636 I regret to inform that your suggestion did not work. :(
When I added that code, the player would try to jump, but would only be able to bounce 1 pixel off the ground. Even after changing the numbers, the results were not what I was hoping for. I even tried this in the platformer example to see if I was doing something wrong, and when I put in the exact code that you provided, Kenney (The little alien) jumped too high, and I couldn't control the height of his jumps. Not even with button taps.
Is there another solution? BTW, my player does not have his hitbox as a separate object. The player is his own hitbox if that helps anything.
By MattLB
#70647 I forgot to mention I'd also reduced the default jump speed to 400, but regardless I spotted that you could continue to rise higher and higher with rapid pressing of space, so I corrected that. Project is attached.
Attachments
(145.68 KiB) Downloaded 8 times