Ask here your questions to get help using GDevelop.
User avatar
By Palsa
#63265 I was following the tutorial for a platformer game, and noticed that the character will bounce if the player is still holding down the jump button when they land on the ground. Since holding down the jump button increases the duration of the jump, this can become rather annoying if your trying to time your movements while crossing a difficult area. Is there any particular way to prevent the player character from jumping once they come into contact with the ground, while still holding the button down?
In other words, have it so that the player only jumps when the button is pressed, and not when it's held down or released.
User avatar
By Lizard-13
#63279 You can try this:
Events.png
Events.png (5.42 KiB) Viewed 383 times

The parent event (event 1) will be launched each time you press Space for the first time, if you hold the key down the event won't keep launching until you release Space and press it again.
The sub-event only runs after the parent runs, so each time you press Space for the first time the parent will be launched, it has no actions but the sub-event will be launched too and the player jumps, if you hold down Space the parent won't run so the sub-event won't run :)
User avatar
By Palsa
#63295 I'm not sure why, but it didn't seem to work for me, after playing around with it I managed to get it to work though.
I have a double jump command for the character, which I thought might have been interfering in some way, so I tried deleting that, but it still didn't work. I also tried it on a fresh platformer game, but it didn't work there either.
However, when I replace 'Player is on Floor' with 'Player is Jumping' and set the action to 'Ignore default controls for Player: yes', it seemed to work, but the player controls for left and right were frozen and I had to reset all of the movement simulations, it also stopped the ladder function from working altogether.
The solution seemed to be having the condition 'Player is on Floor' with 'Ignore default controls for Player: yes' as an action, and also having the condition 'Player is Jumping' with 'Ignore default controls for Player: no' as an action; each as their own independent conditions, and keeping the simulations for left and right movement.
So basically:

Image

There is probably a better way than this, but it seems to do the trick for now.

Thank you for the help! ^_^
I would never have thought of looking in the platform behavior area. ^_^;
By MattLB
#63337 There seem to be quite a few conditions that are checking whether the player is jumping or on the floor, so one might be overriding another.

One thing you could do to neaten things up is merge events 6 and 7 into one event that checks for jumping, with two sub-events that then check the value of the jumping variable.

Altering event 9 with a subevent so it is like this might work to stop bouncing:

Code: Select allPlayer is on floor     |     Do =0  to variable Jumps of Player
           Space key is released  |  Do =2  to variable Jumps of Player


This should set the number of jumps to zero on landing (stopping a bounce), but if the spacebar isn't being pressed it will immediately be set to 2 instead, allowing a jump in event 10.
User avatar
By Palsa
#63402 Sorry for the late response, I've been a bit under the weather. ^_^;

I just tried both, but it didn't work do to the variables, so I switched the numbers 0 and 2 around and it worked.
The problem I'm actually having is not related to this issue, I did managed to fix the bouncing issue, the problem is the way I went about it was by using the 'Ignore default controls for player' command, which disables other functions and has to be rest afterwords.
Basically, what I'm trying to figure out is how to get the same result, without having to use that particular command.