constraining an actor position to a rotating actor

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

Best Answers

  • MobileRocketGamesMobileRocketGames Posts: 128
    edited November 2012 Accepted Answer
    You 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
    This will make something rotate 100 pixels away from an object (in this case, scene.Object).
    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
    The only difference is we are telling it to start rotating at 45, 135, 225 or 315 degrees, which are the corners of a square. The 100 will have to be adjusted to the size of whatever they are rotating around.

    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 :D

    Edited: Forum did something wonky to my formulas. Cleaned it up.
  • MobileRocketGamesMobileRocketGames Posts: 128
    Accepted Answer
    Teach a man to fish @Uptimistik :>

Answers

Sign In or Register to comment.