r/gamemaker • • 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

11 comments sorted by

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?

1

u/Playful_Ease4321 10d ago

A dash mechanic that functions in all eight directions—horizontal, vertical, and diagonal—where the dash is executed when a button is pressed, provided the directional conditions are met. To be more specific—since my previous explanation was quite vague—I haven't been able to implement the timer, the logic for whether a dash is currently possible, the determination of the dash's direction, or the speed at which it moves the player.

2

u/Cheyomi832 10d ago

Do you have a movement system already? Dashes are just your movement code, but you multiply one variable by like 5.

2

u/Playful_Ease4321 9d ago

Just the movement system

2

u/JaXm 10d ago

can_dash = keyboard_check(///select a key///)

dash_speed = can_dash * 2;

move_and_collide(_xinput*Player_speed+dash_speed,_yinput*Player_speed+dash_speed,Obj_colisao);

1

u/Playful_Ease4321 9d ago

So i put it after my movement code?

1

u/JaXm 9d ago

Read the code I wrote, and you'll understand, bro. 

2

u/Krilantis 10d ago • Bravo

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.)

1

u/Playful_Ease4321 10d ago

Thanks man

1

u/Krilantis 10d ago

Anytime! Feel free to ask us what ever. My team is always ready to help. 

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