8 ways movement 2D topdown : keys release issue

Godot Version

4.2.2

Question

hello,I’m not good at english speaking,sorry for that.I’m going to make a 8 ways movement topdown 2D ARPG , but i got a trouble . If press double arrow keys at the same time , for example “down”+“right” : when “down” is just release first, I wish there is a Timer(about 0.5s) as safe_release_time to ensure that the move direction keep South-East ,and when “right” is just release before Timer.time_out ,the idle direction also keep South-East ; elif Timer.time_out ,the move direction and the idle direction keep East . Or if “right” is just release first , when Timer.time_out , the move direction and the idle direction keep South . I’m a newbie ,it’s too hard for me .Thanks !:pray:

You need to keep track of the which key is pressed. Then when that key is released, begin the timer (There’s one built-in in Godot) and DON’T update that key is not pressed anymore. Only update that key isn’t pressed anymore after the timer run out.

This solution still has a lot of issue depend on how you use it but it should be a good starting point. Good luck!

1 Like

Thank you! I’ve tried it with FSM, it works!