Rotate around a center point while that center point is moving

Player_EPlayer_E Member, PRO Posts: 604
edited November -1 in Working with GS (Mac)
Okay here is my current issue.

I have 5 actors in the current placement (crudely graphed below)

B
E A C
D

actor "A" is the center and actors "B,C,D,E" are placed around it like shown above.

Now I am trying to get actors "B,C,D,E" to rotate around the actor A while Actor "A" is floating around the screen bouncing off the walls. I want "B,C,D,E" to keep the same distance between each other that way it will look nice and clean.

Anyone have an Idea of the best way to achieve this?

Comments

  • Player_EPlayer_E Member, PRO Posts: 604
    Hmm seems like my crude graph didnt turn out lol

    picture the graph like this +
  • StrobanikStrobanik Member Posts: 77
    hiya

    unfortunately you can't change the pivot point in gamesalad, actors always rotates around the center of the png. So an idea is to make a big invisible PNG and then place BCDE in the right distance to the center of that PNG. Then constrain that PNG to you actor A and make it rotate. If you want BCDE to have different distances, you will have to make a PNG for each and every one of them. Then you could also give them different rotate speeds, which I think would look nice.

    Hope that makes sense.
  • BeyondtheTechBeyondtheTech Member Posts: 809
    Sorry, my math is a little fuzzy and it's late at night, but I think you're trying to do basically draw a circle around an object.

    http://www.nsbasic.com/palm/info/technotes/TN25a.htm

    It's basically
    X = OriginX + cos(degree) * radius
    Y = OriginY + sin(degree) * radius

    So, set the degrees for each of B, C, D, E to 0, 90, 180, 270, respectively, and increase it.
  • Player_EPlayer_E Member, PRO Posts: 604
    I am currently testing with the tutorial I found in the "how to's"

    I am using : How do I make an actor move in a perfect circle?

    with the following rules;

    Constrain attribute
    self.Position.X to 65*cos( self.Time *200%360)+ game.Center X

    Constrain attribute
    self.Position.Y to 65*sin( self.Time *200%360)+ game.Center Y

    This is working perfectly, but when I apply this rule to all 4 actors they all seem to start out at the 0 degree and rotate together so it looks like 1 actor.

    Any thoughts on how to make them start at 0 Degree, 90 degree, 180 degree, and 270 degree?
  • Player_EPlayer_E Member, PRO Posts: 604
    Any one have some thoughts that can help me out with this?
  • BarkBarkCoBarkBarkCo Member Posts: 1,400
    In an attempt to point you in the right direction I have posted a demo...You'll have to ask Eastbound about the math on this one as it was stolen from his tower defense demo, but this does what you are looking for with one actor.

    http://gamesalad.com/game/play/61005
  • BarkBarkCoBarkBarkCo Member Posts: 1,400
    I updated the demo to work with 4 actors.
  • Player_EPlayer_E Member, PRO Posts: 604
    Thanks ill check it out
  • rebumprebump Member Posts: 1,058
    AdAdo's Star Keep does this.

    I have a few demos that do this as well...although mostly with one actor about the other. Would just have to add three more with the appropriate degree offset added to them.
  • Player_EPlayer_E Member, PRO Posts: 604
    Thanks guys I got it working how I wanted!

    your method was helpful, but the actors them self rotated even when I took off the rotate rule that you have in place. Since I have a drop shadow on my actor it did not look right, so I kind of fused your method and my method together and got it working nicely and my drop shadow stays in the same place. here is what I did incase anyone wants to try it out

    Actor 1
    constrain attribute
    Self position X to game.Center X +65*cos( self.Time *200%360)
    Self position Y to game.Center Y +65*sin( self.Time *200%360)

    Actor 2
    constrain attribute
    Self position X to game.Center X +65*cos( self.Time *200%360+90)
    Self position Y to game.Center Y +65*sin( self.Time *200%360+90)

    Actor 3
    constrain attribute
    Self position X to game.Center X +65*cos( self.Time *200%360+180)
    Self position Y to game.Center Y +65*sin( self.Time *200%360+180)

    Actor 4
    constrain attribute
    Self position X to game.Center X +65*cos( self.Time *200%360+270)
    Self position Y to game.Center Y +65*sin( self.Time *200%360+270)
Sign In or Register to comment.