How do you make it so that "If Input.is_action_just_pressed" require two keys to activate?

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

(I’m new, please bear with me)
I’m trying to make my character have recoil when jumping off walls, but I’m not sure how to tell the engine the direction to push the character away from the wall. As in, how to make the character go right if I walk into the wall from the left.

I thought I could do something like:

const WALL JUMP = -250
const WALL RECOIL = 100

If Input.is action just pressed(“ui up”, “ui right”):

  • motion.y = WALL JUMP
  • motion.x = WALL RECOIL

If Input.is action just pressed(“ui up”, “ui left”):

  • motion.y = WALL JUMP
  • motion.x = -WALL RECOIL

(I didn’t put underscores here cuz that makes it italic)
But that just crashes the game.
Is there a way to make it require two keys to be pressed instead of just one?
Thanks for your time

:bust_in_silhouette: Reply From: kidscancode

FYI, you format code by putting four spaces in front of it, or by clicking the “code” button above the post.

You are trying to check for two separate actions, so you need to check for each of them:

if Input.is_action_just_pressed("ui_up") and Input.is_action_just_pressed("ui_right"):