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!
I have two objects (Wagon and Turret) and I want the turret attached to the wagon. I found out that lengthdir is the one to use for this. But I'm no programmer/scripter so who can help me out step for step.
The easiest way is to find the angle from the origins and distance of the turret.
Then, use something like:
Code:
x = wagon.x + lengthdir_x(wagon.image_angle + aoffset, offset);
Y = wagon.y + lengthdir_y(wagon.image_angle + aoffset, offset);
Where aoffset is the angle offset, and offset is the distance offset.
A more complicated approach is using matrices.
You must first find the x and y offset of the turret. Let's call them xoff and yoff.
Then, use the following code:
Code:
//build the transform matrix from the wagon
var mat = matrix_build(wagon.x, wagon.y, 0, 0, 0, wagon.image_angle, 1,1,1);
//transform our offsets
var o = matrix_transform_vertex(mat, xoff, yoff, 0);
//get our x and y coords
x = o[0];
y = o[1];