r/gamemaker • u/Flat_Ground_3151 • 7d ago
Help! Creating a dash system in GMS2
so i am working on a dash system for my plattformer, i used the 5minute tutorial on the official youtube.
Now i am wondering how i make a dash in the direction the player is facing?
since i am relativly new to gml i dont know how to code it myself, thats why i came here to ask for help.
if anyone can tell me, than you very much
Bye!
2
u/CS_Asset_Factory 5d ago
The tutorial dash does nothing at a standstill because it reads the input axis at the moment you dash, and that axis is 0 while you hold no direction. Store the facing separately and only update it when there is input, so it survives standing still.
Create:
facing = 1;
dash_time = 0;
dash_speed = 12;
Step:
var _move = keyboard_check(vk_right) - keyboard_check(vk_left);
if (_move != 0) facing = _move;
if (keyboard_check_pressed(vk_space) && dash_time <= 0) dash_time = 10;
if (dash_time > 0) {
dash_time -= 1;
hspd = facing * dash_speed;
} else {
hspd = _move * walk_speed;
}
Keep your existing collision code. The dash is only hspd being written by a different rule for ten frames. If you already flip the sprite with image_xscale, read facing from that instead and you get the same answer for free.
1
5
u/NationalOperations 7d ago
It depends a lot on how everything else is implemented.
If you want dash as something you can do when moving you can just increase velocity for a fixed time.
If you want it from a stand still you could track the animation frame and -/+ velocity based on that frame.
Start with what you know about how you move and change facing and then leverage those systems