Holding the jump key should not make the character hop forever
Some games jump again the instant you land if the key is still down, others never jump at all after the first press. The right behaviour needs one small memory of what the key did last. Here is the rule and the case where it goes wrong.
Why this works
A press is something the player does at one moment, while holding is a state that lasts. If the game confuses them, one decision gets read again and again. Reacting to the change, not to the condition, makes each action a separate choice.
When not to use it
Skip it when holding is the intended action, as in a game where the character should keep jumping while the button is down, such as a bouncing runner or an easy mode for players who cannot tap quickly. Offer that as an option rather than the rule.
In the full entry
- What to build, step by step
- Starting values and the reason for each
- 4 common mistakes and the fix
- A diagram of every state
- 34 lines of example code with 3 checks that pass
- How your AI shows you that it works
Say this to your AI
Use the Spielerando entry "Holding the jump key should not make the character hop forever" (read_entry holding-jump-key-must-not-bunny-hop) in my game. Build it step by step, and show me how you checked that it works.Or skip this and connect the MCP: your AI then finds all of this by itself.Connect the MCP