Actor 2 constraining to Actor 1 but not rotating - Help

JCFordJCFord Member Posts: 785
edited November -1 in Working with GS (Mac)
I have my main actor 1 which I move and rotate around the screen.

I am constraining actor 2 to actor 1 with a slight offset, this part works great but when I rotate my main actor 2, actor 1 doesn't follow and I am having problems getting this part to work.

I have the following.

Actor 1 (main actor) have 2 real attributes I call TARGET X and TARGET Y

On actor 2 I have:
constrain attribute
self.position X to game.targetX+30 (slight offset)
self.position Y to game.targetY

I just can't work out what sort of rotate attribute I need to add so if follows in the right location when actor 1 rotates.

Comments

  • firemaplegamesfiremaplegames Member Posts: 3,211
    can you simply constrain self.Rotation To: game.targetRotation?

    that's just off the top of my head...
    it probably requires more math to maintain the angular velocity
  • JCFordJCFord Member Posts: 785
    It works the second actor is rotating on its own centrepoint the same as actor 1 but because I need to offset Actor 2 by + 30 pixels its making it always stay on the right of actor 1 and not rotate around with actor 1 if that makes sense.
  • firemaplegamesfiremaplegames Member Posts: 3,211
    right...

    ok, try this:

    Constrain Attribute
    self.Rotation To: vectorToAngle( self.Position.X - game.targetX , self.Position.Y - game.targetY )

    That might work...
    Otherwise you're going to have to break out those trig books!

    Joe
  • JCFordJCFord Member Posts: 785
    I saw a similar post but where is 'VectortoAngel' I can't find that in the expressions?
  • firemaplegamesfiremaplegames Member Posts: 3,211
    it's in there...
    in the expression editor. the little 'e'
  • JCFordJCFord Member Posts: 785
    Found it - thanks. Still not working, but now I know that's there I will have a little play and see if I can stumble on the right formula.

    Thanks for your help Joe
  • firemaplegamesfiremaplegames Member Posts: 3,211
    it will most likely be a combo of sine and cosine, but am not good at trig by any means...
    good luck!
  • JCFordJCFord Member Posts: 785
    GOT IT! - Yes your right Joe in the end I had to use sine & cosine but now I have an offset Actor that rotates with the main Actor.
  • firemaplegamesfiremaplegames Member Posts: 3,211
    nice! please post the formula!
  • JCFordJCFord Member Posts: 785
    CONSTRAIN ATTRIBUTE
    self.Position.X to 30*cos(game.TargetRotation)+game.TargetX
    self.Position.Y to 30*sin(game.TargetRotation)+game.TargetY
  • GamersRejoiceGamersRejoice Member Posts: 817
    JCFord I've been trying to figure this out for days now and I've tried to put together what I've found in this thread. Could you please go into more detail on how you did this?
  • GamersRejoiceGamersRejoice Member Posts: 817
    bump
  • iAppleDeviAppleDev Member Posts: 13
    Hey I have been trying to work something similar out for a long time. Will this work to constrain a couple actors to the bottom two corners of an actor like tires on a car?
Sign In or Register to comment.