• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

GML automatic movement?

Unarthadox

Member
i know i use hspeed and vspeed but how do i make it cancel when i press another arrow key? my code:upload_2020-1-15_11-25-13.png its just the same for each one except down and up is vspeed.
 

Binsk

Member
Whatever it is set to is the speed it will move. This means if it is set to 0 then it won't move.

When you press another arrow (like up) stop hspeed by setting to 0.
 

sinigrimi

Member
Code:
step event:
hspeed = 0;
vspeed =0; 
if(keyboard_check_vk_left)){
hspeed = -1;
}
step event:
if(keyboard_check(vk_right)){
hspeed = 1;
}
step event:
if(keyboard_check(vk_up)){
vspeed = -1;
}
step event:
if(keyboard_check(vk_down)){
vspeed = 1;
}

but I think that using vspeed and hspeed is a bad option for moving a character
 
Top