Help me please!!! Orbit

Hi everyone.
I'm trying to create a new game where the object orbit around another.
I can only make orbit an object, because the others overlap with the latter.
The code I use is this

I constrain attribute self.position.X to 100°cos(self.Time°200%360)+game.SunX
and the self.position.Y to 100°sin(self.Time°200%360)+game.SunY

How do I make 2 or more objects orbiting in the same orbit at different distances (such as one at 90 ° and another at 180 ° C)?
what code should I use?

Thanks in advance

Comments

  • SocksSocks London, UK.Member Posts: 12,822
    edited October 2014

    @advicegames said:
    Hi everyone.
    I'm trying to create a new game where the object orbit around another.
    I can only make orbit an object, because the others overlap with the latter.
    The code I use is this

    I constrain attribute self.position.X to 100°cos(self.Time°200%360)+game.SunX
    and the self.position.Y to 100°sin(self.Time°200%360)+game.SunY

    How do I make 2 or more objects orbiting in the same orbit at different distances (such as one at 90 ° and another at 180 ° C)?
    what code should I use?

    Thanks in advance

    self.position.X to 100 x cos(self.Time x 200%360)+game.SunX

    self.position.Y to 100 x sin(self.Time x 200%360)+game.SunY

    You don't need %360

    So let's lose that . . . .

    self.position.X to 100 x cos(self.Time x 200)+game.SunX

    self.position.Y to 100 x sin(self.Time x 200)+game.SunY

    If you want to offset an angle you just need to offset the angle the sin/cos is operating on, like this . .

    self.position.X to 100 x cos((self.Time x 200)+180)+game.SunX

    self.position.Y to 100 x sin((self.Time x 200)+180)+game.SunY

  • advicegamesadvicegames Member Posts: 27

    Perfect. Thanks a lot :smile:

Sign In or Register to comment.