How can you create a single stroke key press jump?

How’s it going everyone. I have been working on a beginners platform game. It is a Mario Bros. style jumping platform game. Single key press assigned to a single jump mechanism. Then resets your time to jump again after landing. It’s hard to explain my apologies.

So far I have used the integrated platform engine that comes with GDevelop with great results. I have integrated holding the “Space” bar to adjust my jump height with no problem but I have been stumped the past 2 days looking everywhere on how to achieve a single key press jump with no luck. I hold down the “Space” key and it does multiple jumps as long as I keep it there.

Some solutions I thought about: Possibly to use a timer on how often you can press the key?
Cancel a key press with active and inactive variables?

I may be overthinking and there’s a simple solution maybe? Thank you in advance. If you have any questions regarding my project feel free to ask. Appreciate your time to read this.

1 Like

don’t know if i understand well, maybe a variable is jumping in case to check when you press space?
You want only. one jumpnper keypress right?

Yes. One keypress jump. I just do not know how to limit the keypress to just one. I know what variables is I just cannot wrap my head on how to use them to their best potential. I understand they store information.

if you want share your code i think i can fix it

In the conditions, you will find an Advanced category and a “Once while true” condition.
There’s also a condition “Object is on the floor” if you’re using the platformer behaviour. (Object is in collision with Object2, if you’re not using behaviours)

1 Like

After doing a bit research on “Once while true” and reading on an example of a memory card game tutorial. I was able to figure it out. It was more simple than I imagined. Mixing your suggestions and what I read just worked amazing.

I first tried this strategy on a brand new empty platform game. Just a simple 32x32 square as “Player”, and the “Floor”. Both with their respective behaviors of “Platfomer Character” and “Platform”. NOTE: I ticked OFF the “Default Control” on my “Platformer Character” and assigned the respective actions to their assigned conditions under the “Platform Behavior”

ex: “Right key press”= “Simulate Right press”.
(Condition) (Action)

Now for the main point of the topic. This was my solution. Hope it works for whoever reads this.
For my player

  1. I use the condition “Space key pressed” for my jumping button.

2.Right under than I used the second condition “Trigger Once”

Then a key element I was missing and overlooked a million times was the use of a sub-event with it. Everything else went under in that section after.

3.As a sub-event I used “Object is on floor”, because I am using the engines built in platform behaviors.

4.Las thing was, for the sub-event action section, I used “Simulate pressing Jump key”

Notice I did not use any actions for the first conditions of the keypress and “Trigger Once”.

That worked like a charm! I want to thank you for helping out. I found this instance to be a rare topic to find for me. Maybe it is common sense, but to some of us beginners feels good to learn more and more each day about game developing with this amazing program.

4 Likes