How do I get this to stop leaving orbit?

  • For whatever reason the 1st circle is going out of orbit even though it should be moving at 45 degrees relative to the angle towards the 2nd circle. Am i doing something wrong here or is it bugged?

  • That isn't how orbits work...

    In a stable orbit, no constant forces besides gravity should be acting upon an object.

    The forward momentum should be preserved and the angle of motion set perpendicular to the angle of gravity.

    The magnitude of forward momentum depends on the distance from the center and the amount of gravity acting upon the object.

    Anyways even if you get the math right, setting up a stable orbit with physics is going to be inconsistent at best. Recommend toggling an orbiting state, turning off physics, and using the orbit behavior when appropriate instead.

  • Thank you for you're response.

    I do understand how orbit works but I couldn't be bothered setting it up and figured this would give a similar enough result, any idea why it doesn't?

  • It doesn't work because nothing in a normal orbit has to do with a 45 degree angle between anything.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Gravity is just applying a force toward the planet. Not just any force, it should depend on the distance from the planet to be closer to real physics.

    Something like this:

    force 10000/distance(self.X,self.Y,earth.X,earth.Y)^2 toward (planet.x, planet.y)

    For an orbit you just set an initial velocity. Using an impulse to do that works too. Just make it perpendicular to the direction to the planet.

    Something like this:

    impulse: 50/distance(self.X,self.Y,earth.X,earth.Y) at angle(self.X,self.Y,earth.X,earth.Y)+90

    The 10000 and 50 were purely arbitrary. I just tuned them till i got something reasonable. the 10000 defined how strong the gravity was, and the 50 gave me orbits that lasted a while.

    If you're curious there are perfect values that can be calculated in real life, but the units with the physics behavior are wonky so I just fudged it to get something reasonable.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)