G
Glenn1990
Guest
Hello,
I'm trying to have an object 'locked' to another, so when the primary object rotates the secondary object will rotate around it at a fixed distance away from the primary.
For example a rocket booster on the back of a ship. As the ship rotates the booster always stays at the back of the ship at the same distance away from the ships origin.
I have this code on the secondary object and it seems to work fine:
x = parentObject.x + lengthdir_x(64, parentObject.image_angle);
y = parentObject.y + lengthdir_y(64, parentObject.image_angle);
However if i change one of the distance values (64) so they are no longer equal, the distance between the primary and secondary objects seems to change. Making the secondary move either closer to or away from the primary.
For example:
x = parentObject.x + lengthdir_x(256, parentObject.image_angle);
y = parentObject.y + lengthdir_y(64, parentObject.image_angle);
This has really got me stumped as I want the x and y to have different distances away from the primary origin, any help would be great.
Thanks.
I'm trying to have an object 'locked' to another, so when the primary object rotates the secondary object will rotate around it at a fixed distance away from the primary.
For example a rocket booster on the back of a ship. As the ship rotates the booster always stays at the back of the ship at the same distance away from the ships origin.
I have this code on the secondary object and it seems to work fine:
x = parentObject.x + lengthdir_x(64, parentObject.image_angle);
y = parentObject.y + lengthdir_y(64, parentObject.image_angle);
However if i change one of the distance values (64) so they are no longer equal, the distance between the primary and secondary objects seems to change. Making the secondary move either closer to or away from the primary.
For example:
x = parentObject.x + lengthdir_x(256, parentObject.image_angle);
y = parentObject.y + lengthdir_y(64, parentObject.image_angle);
This has really got me stumped as I want the x and y to have different distances away from the primary origin, any help would be great.
Thanks.