I am using WASD keys to move player but when two of these keys are pressed at the same time the player stops moving
How can i make it so that the player will move toward the key which was last pressed
EX. (W is pressed and i press A at the same time the player should go to left)
I’m assuming you’re trying to implement top-down style movement (if not then it’s impossible to tell from your post).
You can just use the TopDownMovement behavior and disable diagonals and make your events look like this:
If you don’t want any drifting change the deceleration to high number like 10000
I am doing top down movement just like you have posted i have tried this method too and what happens when you press two keys together it just slides in the direction last key was pressed. That is why i switched to the event i posted above
This is what i was using
Did you mean to say the direction of the first key pressed? Is there a particular functionality reason you want to implement this feature, or is it just a “quality of life” thing?
Do you mind changing the character’s acceleration? Because it seems to me that it only slides while accelerating, but stops sliding when it reaches the speed limit. If you put a very high acceleration, I believe it will not slide. But I don’t know if this change in your game is unwelcome.
And maybe we can think about open a post in bug report?
the direction of the first key pressed? No
I mean the direction of the last key pressed
If you are using W to move forward and while keeping the W pressed you press A the player will face in the north direction but it will start to move the left and no animation will be played and as soon as you release W it will turn to left and the animation will start playing too.
It’s a quality of life thing but important i would say
I did changed the acceleration as you said but nothing happened, same result
Okay now I understand what the big problem is. It’s because you’re using animations for the player instead of using the rotate option with the TopDownMovement extension. Honestly I think the best option here would be to go back to the previous event setup with TopDownMovement (like the screenshot I sent) and then make the rotation a large number (I used 5000 and it worked pretty well), when it’s that high you can’t even see the rotation happening so it looks as if the player instantly faces in the right direction. Although this probably wouldn’t work if the player has a special walking animation for each direction.
In that case you might be able to do something like your previous setup except make the other key presses subevents that each trigger their respective animations (no promises on this working it’s just a guess).
I tried but still not working
I uploaded a gif