HELP - Orbiting Problem for T-Shirtbooth / FMG / and other Math Freaks

JCFordJCFord Member Posts: 785
edited November -1 in Working with GS (Mac)
Hello fellow GS Users

I have an Orbiting Problem that I can't resolve, I will do my best to explain the issue!

I have a central actor called "BOX" and I have another actor called "CIRCLE" which is rotating 100 pixels offset around this "BOX" using the following.

CONSTRAIN "CIRCLE" ATRIBUTE
self.Position.X to self.100 *cos( self.Time *-30%360)+ game.BoxX
self.Position.Y to self.100 *cos( self.Time *-30%360)+ game.BoxY

This all works fine, but I wanted to make it so that I can drag the "CIRCLE" actor anywhere on the screen and when dropped it will still rotate around the "BOX" actor in its new offset position.

So along with a Drag attribute I have used the good old Magnitude as follows:
self.MyPosition to magnitude(abs( self.Position.X - game.BoxX ),abs( self.Position.Y - game.BoxY ))

I then revised my original Attribute from the 100 pixel offset to self.MyPosition
CONSTRAIN "CIRCLE" ATRIBUTE
self.Position.X to self.MyPosition *cos( self.Time *-30%360)+ game.SunY
self.Position.Y to self.MyPosition *cos( self.Time *-30%360)+ game.SunY

Now this all works the CIRCLE rotates around the BOX and I can pick up the CIRCLE and drop it anywhere on the screen and it will offset the correct amount so it is no longer at 100 pixels offset, i.e. if I move it 200 pixels away it will drop off 200 pixels away yippppeeeeeee.

BUT the problem is the CIRCLE seems to want to jump to where it was on its original 360 degree path around the BOX, but I want it to continue from where I dropped it off. i.e. IF I pick it up 100 pixels on the left of the BOX and quickly move it 300 pixels to the right of the BOX it, will stay at 300 pixels away from the BOX, but it jumps around to where it would be (360 degrees) if it had continuted on the original path!

I just can't get my head round this one, maybe need some sleep. off to bed.

Comments

  • ORBZORBZ Member Posts: 1,304
    It's because self.time keeps ticking even while you're dragging it. Capture self.time at the moment of pickup and subtract that amount from self.time in the formula above.

    sin(self.time - pickupTime * -30*360)

    Also, the Y value should be using sin not cos.

    Also useful: Orbital Acceleration

    a=v^2/r
  • jonmulcahyjonmulcahy Member, Sous Chef Posts: 10,408
    yea, I've got some math questions I'll have to throw your way :)
  • JCFordJCFord Member Posts: 785
    @ ORBZ - Thank you sir, I tip my hat to your math knowledge!
    JCFord
  • JCFordJCFord Member Posts: 785
    Hi ORBZ - Completely understand what you mean in concept, but when I implement it t as you stated above the planet no longer rotates because it appears to be taking away pickupTime from self.time.

    Any advice?
  • victorkin11victorkin11 Member Posts: 251
    What i think is

    delaytime = (releasetime-picktime)

    so

    sin((self.time - delaytimeTime) * -30*360)

    but when you pickup it again, the delaytime should be

    delaytime = delaytime+(releasetime-picktime)
  • ORBZORBZ Member Posts: 1,304
    ya, i think i got my math wrong there... but you got the concept right.
  • jonmulcahyjonmulcahy Member, Sous Chef Posts: 10,408
    I'm trying to tweak this to work on a project of mine, but I'm having some difficulty wrapping my head around the delaytime section. How are you calculating that? This is the road I'm going down, but I don't know if it's right:

    When actor receives Touch down
    set self.pickupTime to self.Time

    When actor receives Touch Up
    set self.releaseTime to self.Time

    Is that right? How would I apply the 2nd pickup?
  • jonmulcahyjonmulcahy Member, Sous Chef Posts: 10,408
    ok, I tried what I have above. when my actor moves from one island to another, he still starts orbiting at the top of the circle, but when I click on him to leave, he leaves as if he had been orbiting from where he originally arrived. Does that make sense?
  • jonmulcahyjonmulcahy Member, Sous Chef Posts: 10,408
    never mind, I've done away with the orbiting and are just having the actors overlap and rotate on the same center point. It's a hell of a lot easier for me to work with :), and actually makes more sense for the game I'm working on. In 90 minutes I've got the framework for my game done. I just need to flesh it out with extras, levels and stuff, but the core exists.

    show me another tool I could do that with ;)
Sign In or Register to comment.