Vector to angle question.
Okay so I'm a wiz at logic but I suck at vector math. I have an actor that rotates 360*. I have a second actor attached to it with an offset. I need the attached object to move with the main object as it rotates. Thanxs in advance to the math wiz!
Comments
constrain selfposition.X to
mainactor position X + (offset * cos(angle.mainactor))
constrain selfposition.Y to
mainactor position Y + (offset * sin(angle.mainactor))
Hope that helps. It came out my head so not sure if I made a mistake
edit: if you want the orbiting actor to rotate too simply constrain its rotation to the rotation of the main actor (add a value like for example +45 if the initial is incorrect)
edit2: Turned around the cos and sin
Here it is
Actor one X - magnitude (OffsetX,OffsetY)*sin((Actor.one.Rotation)-atan(offsetX/offsetY))
Actor one Y + magnitude (OffsetX,OffsetY)*cos((Actor.one.Rotation)-atan(offsetX/offsetY))
Now on to the next puzzle but I think I have that formula getting it to move in that vector lane up and down.
I thought I had put something like this in the "Spare Code" discussion. But I can't find it there. Here it is. The 'code' is comparable to Ludwigs. But my graphics are not nearly as nice.
http://www.mediafire.com/download/zpgd9040t34z3be/FerrisWheel.zip