[SOLVED] TopDown two buttons pressed movement

Hello.
I am making a topdown movement, and I want my character to only move 4 directions.
I simply unchecked the “allow diagonals” in the topdown movement extensions and it worked.

But, when I press 2 keys (let’s say Up+Right) my character stop having an animation and goes either up or right, depending on the latest key pressed.

I want to not allow the player to press two keys at the same time, but everything I’ve tried failed. I have already followed several discussions here but none of them worked. I think the reason is because the movement is not in the code, the extension is doing it. Which makes everything really complicated.
I’ve already tried deactivating the extension when two keys are pressed but I wasn’t able to reactivate it without it letting the character move with 2 keys pressed, I’m not sure it’s the way to go.

If two keys (Up+right) are pressed, nothing should happen. When they are released and one key (Up) is pressed, it should work (character goes up)

How do I do that.

Thank you in advance for your help.

1 Like

Okay, I see.

I have an idea.
Take the first key press event (the top one in the picture) and in addition to “up key is pressed”, add these to the SAME EVENT (just under the “up is pressed” is okay):

  • down is pressed
  • right is pressed
  • left is pressed
    and then invert these added 3.

This way the action WILL NOT HAPPEN if other buttons are pressed

Then do the same for the other events. So every direction is MENTIONED in every event, 3 are inverted but 1 is normal.

1 Like

Thank you for your answer !
But the action there is not to make the character move, it’s for the animation to play.
That’s my biggest problem : the actual movement is not in the code. The behavior, the topdown extension is doing it.

I did what you said and it just stop hte animation from playing ):

1 Like

How about something like this! I think it works

(this example only targest pressing up and right at the same time, but if you are able to understand the logic behind it, I think it should be easily extendable)

Edit: Yeah like this

2 Likes

It worked !!!

Thank you so so much, I’ve been stuck on this for hours !!

I was using the wrong event to disable the movement, it works like a charm now !

Thank you again, I was getting really desperate :D!

1 Like

I’m just glad I have learned enough myself to finally help someone else. See you next time. This is like 80% desperation and 20% actual progress, at least for me!!!

But we are making progress!

2 Likes

This helped me as well! I was getting so close to just giving up on my project. Thank you so much!!!