scotsparaman
Member
Can anyone help with smooth rotation using the keyboard? so far I have:
With this, if push left or right, nothing happens but if i push up or down the player instance spins in circles.
Looking for the instance to smoothly rotate from its current angle to 90 if going up, 180 if going left etc etc...
Many thanks.
GML:
moveUp = keyboard_check(ord("W"));
moveDown = keyboard_check(ord("S"));
moveRight = keyboard_check(ord("D"));
moveLeft = keyboard_check(ord("A"));
var _horMove = moveRight - moveLeft;
var _verMove = moveDown - moveUp;
if ((_horMove != 0) || (_verMove != 0)) {
var pdir = point_direction(0, 0, _horMove, _verMove);
facing += sin(degtorad(pdir - image_angle)) * tankRotSpeed;;
}
hspd = (moveRight - moveLeft) * moveSpeed;
vspd = (moveDown - moveUp) * moveSpeed;
x += hspd;
y += vspd;
Looking for the instance to smoothly rotate from its current angle to 90 if going up, 180 if going left etc etc...
Many thanks.