Rocket orbiting issues

Discussion in 'Programming' started by Lolasaurus, Aug 13, 2019.

  1. Lolasaurus

    Lolasaurus Member

    Sep 6, 2016
    Hey Guys,

    I'm using some trig functions to simulate a rocket orbit around earth. Changing the direction of the rocket and applying thrust then changes the orbit shape and size etc.

    I am using the SOHCAHTOA principles to achieve this, however in places, often as vspeed crosses over 0, the rocket suddenly shoots off away from the planet. I'm guessing this is because gamemaker has an inverted y axis and so the vertical speed must be switched, however doing so doesn't give me a better result.

    Is there something more I'm missing? If i need to post some code i can do so, I just had little time to write this up.

    Thanks in advance everyone,
  2. IndianaBones

    IndianaBones Member

    Jul 5, 2016
    Seems you are on the right track, but hard to tell without more info.

    Add debug info displaying relevant numbers on-screen. ( x, y, vspeed, hspeed, direction, speed etc... ).

    Observe and check for anomalies to pinpoint what's going wrong.

    Post the relevant parts of your code here, along with a breakdown of what "...the rocket suddenly shoots off away from the planet" entails - (Is there any consistent pattern to it, does it always happen in the same place, does the rocket always shoot off at the same speed and direction etc...) . Diagrams and/or a video if its difficult to explain.
  3. Lolasaurus

    Lolasaurus Member

    Sep 6, 2016
    Okay I definitely had something wrong in that attempt, the orbiting is fixed now and works well, except... The orbit constantly changes, I guess due to rounding of lengthy decimal places etc.

    Here's my simple code, Newtons Gravtitational equation has been simplified there.

    How can I increase the accuracy of the orbit so it maintains the same shape until thrust is applied etc?
  4. NightFrost

    NightFrost Member

    Jun 24, 2016
    That's the nature of gravity. When an object's velocity is small enough, a gravity well will capture it onto an orbit. That orbit will be elliptical and its apogee and perigee will likely move around. A high-velocity object captured after a close pass will form a highly elliptical orbit, while a slow one captured at distance will form a more rounded one. To alter the orbit, thrust must be applied to change the velocity vector. To create an orbit that is approximately circular you either execute a well-planned orbital entry, or the game presents some sort of "orbital docking" feature that throws out gravity and applies cartoon physics to form a circular orbit.

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice