• 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!

Windows Movement problem

Hi, I´m making an RPG game and I use this code in my character´s step event:
GML:
//Estado del jugador
keyLeft = keyboard_check(vk_left);
keyRight = keyboard_check(vk_right);
keyUp = keyboard_check(vk_up);
keyDown = keyboard_check(vk_down);
keyActivate = keyboard_check_pressed(ord("z"));
keyAttack = keyboard_check_pressed(ord("x"));
keyItem = keyboard_check_pressed(vk_shift);

inputDirection = point_direction(0,0,keyRight-keyLeft,keyDown-keyUp);
inputMagnitude = (keyRight - keyLeft != 0) || (keyDown - keyUp != 0);

//Movimiento
hSpeed = lengthdir_x(inputMagnitude * speedWalk , inputDirection);
vSpeed = lengthdir_y(inputMagnitude * speedWalk , inputDirection);

x  += hSpeed*2;
y += vSpeed*2;
My character was moving slow so as you can see I multiplied the hSpeed and vSpeed *2. But now when I move diagonally my character moves slowler. What can I correct?
 
Change speedWalk instead of multiplying the hspeed and vspeed. In terms of vectors, the magnitude is the "speed" at which you will move at, and you are already multiplying the magnitude (which is inputMagnitude) with speedWalk, no need to attempt to add another multiplier somewhere else.
 
Change speedWalk instead of multiplying the hspeed and vspeed. In terms of vectors, the magnitude is the "speed" at which you will move at, and you are already multiplying the magnitude (which is inputMagnitude) with speedWalk, no need to attempt to add another multiplier somewhere else.
It worked, thanks.
 
Top