- #1
sydan
- 5
- 0
Hi there!
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
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