So I have a gravity simulation in which multiple objects are created and are attracted to eachothers by the laws of gravity.
now I am having problems to create stable systems with more then 2 objects.
the goal of my program is to create a stable solar system with multiple planets and moons.
for test purposes I create 1 star, and one planet with a moon.
with some code I let them orbit eachother as they should.
now it looks good in the beginning. the planet orbits the star and the moon orbits the planet
but the problem is that the star has a gravitational pull on the moon. that causes the moon to be pulled out of its circulair orbit. the moon eventually crashes on the planet.
so my question is. is there anyone here who has experience with creating stable systems in a gravity simulations? do you have any tips for me? or is not really possible to make (which I suspect now)