# angular rotation formula

• Hello,

I would like to keep the location of one sprite at an angular rotation relative to another sprite at all time -- based on the angle parameter of the sprite (the direction the first sprite is facing).

So, for example, consider an vehicle traveling right (angle=0), there would be a vehicle 45 degrees to its right and behind it at constant distance d (say 75).

Now, if vehicle1 turns clockwise (its angle becomes say 45), i want the following vehicle on the right, to fall back, to keep to 45 angle and distance d.

This means that the Angle parameter of Vehicle 1 must be translated to an angular rotation of the X,Y coordinates of the following Vehicle 2.

Is there a set of forumals that work in degrees (expected by cos and sin in C3) that could be used?

thanks,

Dan

#### Tagged:

• there would be a vehicle 45 degrees to its right and behind it

45° to it's right would put it in front of it?

But I think I know what you mean. The formula would possibly be:

Set position VehicleB to:

X=VehicleA.X+cos(VehicleA.angle+45)*75

Y=VehicleA.X+sin(CehicleA.angle+45)*75

Is this what you are after?

• ## Try Construct 3

Develop games in your browser. Powerful, performant & highly capable.

Construct 3 users don't see these ads
• Yes, Exactly!

Many thanks for coding it up as well --

Dan