Double Jump Bug

How do I…

Make it so you can only double jump once.

What is the expected result

Jump, while in the air jump again, you are then unable to jump again in the air until you touch the floor.

What is the actual result

You can infinitely double jump.

Related screenshots

For the most part your idea is valid. your variable is not. The red text and squiggly indicate you’ve supplied something invalid. Variable names cannot contain special characters (!?.#@$&*% etc). Remove that from all of your variables and it should (In theory) work fine.

Thank you! Now it doesn’t double jump at all though? Do you know why?

Normally whenever you do “allow jump again” you should also include the “simulate jump key press” in the same action, because “allow jump again” only lasts one frame.

I tried it again, and it doesn’t work, could you tell me why please?

Your event will work if you do a full jump with no jump sustain (e.g. your jump acceleration/speed is 10x your max jump speed), which will make it jump full force like in Castlevania 1 or 2.

If you’re wanting to do a jump with Jump Sustain (where you have to hold jump) your event is going to be quite a bit more complex. However, I’ve set up something similar a while back and still have the screenshot.

The above gives you coyote time and the ability to do jump sustain (without bunny hopping).

What you need to do is the above logic, but also add another boolean for doublejump to the first event (add an action of “set the boolean variable canDoubleJump of Hero to true”). Then you will have a separate event entirely of:

The boolean value canJump of Hero is False          | allow Hero to jump again
The boolean value of canDoubleJump of Hero is True  | simulate pressing jump key for Hero
Space key is pressed                                | set the boolean value of variable canDoubleJump of Hero to false
Trigger once                                        |

The rest of the events should still function as expect. I’d also recommend changing the condition "The timer “coyote” of Hero < 0.084 seconds. Coyote Time is commonly only 5-6 frames in most games, and this roughly equates to 0.833333 seconds.

This event sequence in total does a few things:

  1. Makes sure your player doesn’t bunny hop (Holding down jump starts another jump as soon as they hit the ground)
  2. Allows them to have coyote time (pretty important for platformer "game feel"0
  3. Makes sure the player can have variable jump heights/jump sustain.
  4. Enables a double jump.

Otherwise, you could use this extension.
https://wiki.gdevelop.io/gdevelop5/extensions/advanced-jump/reference

2 Likes