[SOLVED] How do I manage pressing two keys at same time in top down movement?

Hello !

I’m trying to figure out how to use top down movement behavior with the spritesheet extension. It all works fine until I press a second directional key while already pressing a key to move in a certain direction.

Let’s say my character is moving right, so I’m pressing the right arrow key and then I want to move up, so I press the up arrow key but I’m leaving my right arrow key for convenience sake, so that my character will move automatically to the right once I release the up arrow key.

It does so, but it plays the second key’s Idle animation instead of reverting back to the first key’s walk animation.

GDevelop files included

Any ideas ?

game example

As i remember when facing same issue
You need event for if Right is pressed BUT UP and Down is NOT
Then event for if Right is pressed with UP
And another for Right with Down

And repeat for each key with same logic

So each direction you gonna move needs 3 events

Where for UP it would be Up but right and left is not
Up with left
Up with right

And i think (if memory serves) order of events was important here

1 Like

Thank you ZeroX4, I’m going to test this method !

Mine looks like this.

1 Like

Hello KyouJin, thanks ! I’ve tried ZeroX4’s method, while it worked when I pushed Right first it didn’t when I pushed Up first ( the player moving to the right but playing the Up animation).

I’ll try your setup, it looks good to me

Worked like a charm ! Thanks again mate !

Great :slight_smile:
But I think Zero means something similar, but whatever, glad it fits for you!

Absolutely it’s the same idea, your screenshot made me realize I needed to consider diagonal movement for it to work. Thanks to you both :slight_smile:

1 Like