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

Reset direction origin after movement.

ChrisC

Member
im trying to program a car steering. So I need the angle of the wheels to lock relative to the car object. I cant figure out how to tell it to be angle in relation to the object and not the room. I tried this at first.

image_angle = point_direction(x,y,mouse_x,mouse_y);


if (image_angle > 45) && (image_angle <180){ image_angle=45;}
if (image_angle > 180)&& (image_angle <315) {image_angle=315;}

and then movement would be toward mouse

if keyboard_check(ord('W')){
motion_set(image_angle,VanSpeed)

but once i stop the angles still only go from 45 to 315 so i can only travel right.

i need the wheel to pull the car object and then wheel 45 to 315 will be in relation to the car body.
 

jo-thijs

Member
Why don't you just rotate your wheel sprite 90 degrees clockwise and keep angle between 45 and 135 through this code?
Code:
if image_angle >= 270 || image_angle <= 45
    image_angle = 45;
else if image_angle >= 135
    image_angle = 135;
 
Top