Vector to angle question.
The_Gamesalad_Guru
Member Posts: 9,922
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
Send and Receive Data using your own Server Tutorial! | Vote for A Long Way Home on Steam Greenlight! | Ten Years Left
My GameSalad Academy Courses! ◦ Check out my quality templates! ◦ Add me on Skype: braydon_sfx
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
Lump Apps and My Assets
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS
Lump Apps and My Assets
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS
Lump Apps and My Assets
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS
Lump Apps and My Assets
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS
Lump Apps and My Assets
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.
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS
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