Check for single button pressed?


How can I check if only 1or 2 certain button(s) is pressed?

I want to make a top-down/isometric game and the animations overlap when pressing two buttons i.e. (s) and (d) to play the animation that is connected to the “move at a 45° angle”.

I basically just want it to cancel any other movement direction buttons while running in one direction and to detect when two buttons are pressed to move diagonally.

I know I can check for “if buttons not pressed” but that just make things wayyy to complicated and messy.

Is there a condition for this and if not, pls! Can Gdevelop team add this.

Any ideas appreciated.

just to let you know, the topdown behavior does support isometry now

so you can work with just that.

as for the animations and other logic, you can work with

I also recommend to use Variables as states for the player (Finite state machine), to avoid having to use inverted conditions all the time.

here is a screenshot of a part of my controls for the isometry game with heights, to give you an idea of how to use it.

The more states you have/use, the easier it is to work with.

1 Like

Hi ty for the help. I decided to just do this:
If player is moving: Set Animation to 1 + round(Player.TopDownMovement::Angle()/45

The player topdown angle is devided by 45 and rounded.

The “1+” at the beginning is so that animation 0 would be skipped which is the Idle animation

And the animations would be
0: Idle
1: run-right
2: run-downRight
3: run-down
4: run-downLeft
5: run-left
6: run-upLeft
8: run-up right

So if the player is running at a 45° angle (downLeft) it would be 1+(45/45) which would be 2. Then animation 2 is chosen which is the run-downLeft animation.

Same for other 7 angles.

And “If player is moving” - inverted condition then set animation to 0 (idle animation)

This worked fine for me!

But ty for your input. Definitely learned something new!

Edit: the reason I started/put run-right as animation 1 is because In Gdevelop 5, angle 0 is pointed to the right and goes in a clockwise direction so to keep things simple I started at move right.