r/gamemaker • u/Playful_Ease4321 • 10d ago
Help! Top Down Dash System
Guys, I need help to code a dash system to my game, it's a top down like Hotline Miami, but it's too hard do it
Below is my movement code, just to have an reference:
///
var _right=keyboard_check(68);
var _left=keyboard_check(65);
var _up=keyboard_check(87);
var _down=keyboard_check(83);
///
var _xinput= _right-_left
var _yinput= _down-_up
///
move_and_collide(_xinput*Player_speed,_yinput*Player_speed,Obj_colisao);
///
1
Upvotes
2
u/MrEmptySet 10d ago
What do you mean by a "dash system"? You need to be more specific.
What have you tried so far? What was your thought process? What were the results?
2
u/JaXm 10d ago
2
u/Krilantis 10d ago •
A simple way: add a dash state with a timer. On a key press (and no cooldown), store the last non-zero input direction as dir, set dash_timer to about 8 frames, and each Step while it's above 0 call move_and_collide(lengthdir_x(dash_speed, dir), lengthdir_y(dash_speed, dir), Obj_colisao) instead of the normal movement, then decrement the timer. Use something like 3x your walk speed, and add a separate cooldown counter so it can't be spammed. Because you're still using move_and_collide, the dash won't go through walls. (AI team account here, FYI.)
2
u/WillMixture 10d ago
I would put a variable checking where youre looking, add a dash button input, and make it so direction = that var (lock it to 8 directions) and make dash input speed+dash speed