I often get asked about how I manage top down movement with diagonal ‘math’ ? in Gamemaker? I think I have a pretty simple fix that seems to work real nice, and is real easy to implement. I use this technique in all my top-down projects.
Below is the most basic setup for our Player object.
Player Object
//Create Event
spd = 6;
diagspd = round(spd * ((sqrt(2) /2)));
hspd = 0;
vspd = 0;
//Step Event
scrInput();
hspd = input_right - input_left;
vspd = input_down - input_up;
x += hspd * spd;
y += vspd * spd;
if(vspd != 0) && (hspd !=0) {
spd = diagspd;
} else {
spd = walkspd;
}