constraining an actor position to a rotating actor
danshaw
Member Posts: 38
hi,
this is probably a easy question to answer but im a noob....ive got a rectangular actor that i want to constrain a circular actor to the corner of. ive watched the tutorial on how to do this but once the rectangle starts to rotate, the circle doesnt stay on the corner....i understand why but how do you constrain the relative angle of the circle to the square?
thanks!
Dan
this is probably a easy question to answer but im a noob....ive got a rectangular actor that i want to constrain a circular actor to the corner of. ive watched the tutorial on how to do this but once the rectangle starts to rotate, the circle doesnt stay on the corner....i understand why but how do you constrain the relative angle of the circle to the square?
thanks!
Dan
Best Answers
-
MobileRocketGames Posts: 128You just need to add the rotation of the square to your equation.
For example:
To make something rotate in a circle 100 pixels from something, you need two constrain attributes.- Constrain Attribute self.Position.X = 100cos(scene.Object.Rotation)+scene.Object.Position.X
- Constrain Attribute self.Position.Y = 100sin(scene.Object.Rotation)+scene.Object.Position.Y
To make it rotate around the corner of a square you would say:- Constrain Attribute self.Position.X =
100cos(scene.Object.Rotation+45)+scene.Object.Position.X - Constrain Attribute self.Position.Y =
100sin(scene.Object.Rotation+45)+scene.Object.Position.Y
To test this, set up a rule in whatever you are rotating with key left rotating one way and key right rotating the other way.
Also, if you have questions like this its best to create your thread as a question, not a discussion. That way when someone answers your question the thread can be closed and that person can get recognition for their help. You can press the Insightful button below my post if I've been helpful though
Edited: Forum did something wonky to my formulas. Cleaned it up.
Answers