U
Unpopularstream
Guest
I've got an object rotating left and right using A and D with added friction. The rotation works great but I want the object to move forward based on where the front of the sprite is rotated, not just up on the y-axis. Here's my current code so far
Edit: I want to tie moving forward to W
Code:
Create Event:
rotation = 0
Step Event:
// Value of _Direction will be either -1, 0, or 1.
direction = keyboard_check(ord("A")) - keyboard_check(ord("D"));
// Lerp between current rotation value and direction by 1% (increase to make acceleration / deceleration faster).
rotation = lerp(rotation, direction, .02);
// Add to image angle
image_angle += 3*rotation;
//Move toward front of sprite
direction = image_angle
Last edited by a moderator: