Hi there!(adsbygoogle = window.adsbygoogle || []).push({});

I'm developing a game that involves simulating a star system. I'm using the Unity engine and its physics engine. I've got gravity working perfect.

I've also developed an algorithm that works out how much force you would need to apply to a body to start it orbiting around another (stationary) body. It works perfectly; I've made a series of moons orbit a planet without deviation for an unlimited length of time.

The problem I now have is that when I set the planet up to orbit around the star, the moons don't stay with it, they just get left behind.

To try and overcome this problem I made my orbit calculating algorithm recursive so that each moon first works out the force it needs to start orbiting the planet, and then adds that to the force it would need to orbit the sun to try and keep it with the planet.

This didn't work, the moons don't orbit the planet as far as I can tell. All the moons and the planet start orbiting the star and gradually spread out across the orbit so that some moons are ahead and some are behind.

Just so its clear these are perfectly circular orbits. I was just wondering if anybody had any idea how to make the maths work for this? I'm a bit stumped... I can't think how to do it...

Matt

**Physics Forums - The Fusion of Science and Community**

Join Physics Forums Today!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Calculating orbits of moons, when both the planet and star are involved.

Loading...

Similar Threads - Calculating orbits moons | Date |
---|---|

A Calculating the Altitude of a Nominal Burst | Feb 19, 2018 |

B Calculating distances with an elliptical orbit | Jun 6, 2016 |

B Calculating Orbital Velocity in 2D | May 6, 2016 |

Calculating orbitals-rosette | Mar 5, 2015 |

Calculation the orbital period of Moon. | Sep 16, 2014 |

**Physics Forums - The Fusion of Science and Community**