Platformer - No Jump After Landing

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.

You can try this:
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 :slight_smile:

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:

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. ^

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:

Player 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.

Thank you for the suggestion, I’ll give that a try. :smiley:

If that doesn’t work, try setting the condition to “Trigger Once While True”.

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.

I had a play and it was trickier than I thought because the platformer behaviour overrides everything else, so it was necessary to set the jump speed as well as the Jumps variable. It was easy to stop a bounce, but not while still allowing a double-jump. Sub-events did the trick in the end.

Anyway, the pic below shows how to change events 9 and 10. You can then delete events 11 and 12.

As a side note, if you are using the platformer behaviour with default keys then you don’t need the “simulate pressing” actions. The player will jump when space is pressed, or run when left is pressed, regardless of what’s in the events.

Thanks for the suggestions, I’ll give that a try. :smiley:


I just tried it, and found that I couldn’t get it to work without including the Jump Simulation command, but your formula fixed the problem, it works great! :smiley: