Combinating two key to do an action

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By ddz

I’m making a Metroidvania and i wanna make a down air attack.
Down key + attack button on the air, how do i do that?.
I’m a Beginner

:bust_in_silhouette: Reply From: johnygames

First you need to set up the Input Map. I guess you have already set up a key for “down” and another one for “attack”. In the _process(delta) function you can write the following condition:

if Input.is_action_pressed('ui_down') and Input.is_action_pressed("attack"):
    down_air_attack() # function that handles the attack

Now you say this should only happen when you are airborne. Then create a boolean value named airborne, set it to true when the character is in the air and write:

if Input.is_action_pressed('ui_down') and Input.is_action_pressed("attack") and airborne==true:
    down_air_attack() # function that handles the attack