Dash on air/double jump?

I want to make a hope if the player is on the ground. If the player is in the air I want to make a dash with the same button.

If I do not have any events, the player jumps with space as default. If I create Dash for another key for example “left control” it works if I first click Space and then left control. I want to get the same result if you click Space twice, when the player is in the air and clicks Space.

I have tested many variants, some events I have tested. Either the player first makes a dash and then a jump or either does not work dash or jump.

Skärmavbild 2024-12-31 kl. 14.07.36
Skärmavbild 2024-12-31 kl. 14.00.21

I’am using the extension " Advanced platformer movements" Advanced platformer movements - GDevelop documentation

Behavior on my player

I hate that logic cause it confuses us into checking what we should check
Instead of trying to check something else

Imagine this
We have lamp
What you would care about?
Is lamp on off switch either ON or OFF
Pretty simple
BUT what you should check is not state of switch
But is there light or is there no light
Or to be precise can you see or not
And now it start to have totally different meaning even so in the end for us it is same thing more or less

NOW
You should make var that WHEN player is is in air and space key is released
Meaning 1st player need to be in air then space key need to be pressed and released
You set it to true
And now if that var is true
And player is in air you allow player to dash with space
That is how you lock jump key to work as air dash key instead of air jump

You would then need to switch this variable to false

MAYBE better idea would be to go with number variable
By default you set it to 0 in variable window

This is to manipulate state of variable when in air
Condition
Player is in air
Space key is released
Trigger once

Action
Change variable ADD 1

  • Pay close attention to above event
    Each time you press space in air you ADD 1 to variable
    Where last event in my message will be for checking if variable is equal to 1
    So if you dash once then it will become 2 if you press space again it will become 3 and so go on
    BUT you are checking if its equal to 1 where you reset it to 0 with below event if player stand on ground
    So this is just your way to prevent spamming dash in air

This is for manipulate state of variable when on ground so cancel dashing with space and reset var to 0
Condition
Player is on the floor

Action
Change variable SET TO 0

This is to allow player to jump with space when on the floor
Condition
Variable = 0
Space pressed

Action
Jump

This is to allow player to dash with space when in air
Condition
Variable = 1
Space pressed

Action
Dash

  • As i wrote in 1st event here you check if var is equal to 1 to prevent spamming
    You totally could check if variable is equal or higher than 1 and equal or less than 2 and now you have TWO dashes in air
    You could check if var is equal or less than 3 and now you have 3 dashes and so go on
1 Like