GML Locked Circular Rotation

H

Harper

Guest
Hello all!
I've made a simple spaceship that moves in the direction it's facing, how would I get another object to rotate around the spaceship based off of it's direction? For example, if I wanted a engine on the back of my spaceship to rotate around it on x and y based off of the direction the spaceship is facing. Thanks!!!

Click me for an image example if the below image is not working...
Untitled.png
 

NightFrost

Member
You can use lengthdir_x and lengthdir_y to calculate the position. They run a bit of trigonometry to get you the results.
 

CloseRange

Member
here is an example of what the code might look like as Night had said
Code:
// step for engine or something
var offset = 32; // how far back to have object
var angleOffset = 180; // rotation from origional (180 is behind)
var a = obj_spaceship.image_angle + angleOffset;
x = obj_spaceship.x + lengthdir_x(offset, a);
y = obj_spaceship.y + lengthdir_y(offset, a);
image_angle = obj_spaceship.image_angle;
 

Alexx

Member
You could also use a separate sprite with the x origin offset as -distance and set the angle to the spaceships angle -180.
 
Top