Download

Trying to get the Moon to orbit the Earth

In my group project I am trying to get my Moon object to orbit my Earth object planet. However, I’m not too sure on how to do this so any help would be appreciated.

Sorry for not uploading an image, my college’s internet has been really odd today and I’m surprised I even got onto this forum.

You can have a dummy object in the middle of the earth, then place moon according to it’s orbit and link the moon to that dummy and then animate / rotate, the dummy.

There are two ways of going about this…

  1. A physics based approach
  2. An animation approach

The easiest to implement and the most predictable of these is the animation based approach. One way to do this is to attach the moon to a springarm parented to the planet and simply rotate the spring arm on tick.
The physics approach is my favorite, I actually implemented this in a solar system generator project and it was great. This basically involves giving the moon an initial velocity and applying a constant force to the moon in the direction of the planet.

If you are interested in the physics approach, look into Newton’s law of universal gravitation and Kepler’s laws of planetary motion

Physics based approach is a pretty bad idea because most likely you will run into precision issues and the moon will deorbit and crash into the planet or fly away.

I disagree that it is a bad idea however I will admit it is not the most practical approach, also, how much of a bad idea it is depends on the project really. It is entirely possible to obtain stable orbits and I have achieved just that, I didn’t encounter any precision issues and maintained ~120 fps with >12 orbiting bodies, none of which collided with each other or the central body. I’ll admit it was no easy task to obtain stability, especially for >12 bodies, but once I had achieved it the results were really cool. I imagine achieving stability for a single orbiting body would be a much simpler task.

The gravitational laws are easy enough to implement and you’ll get a true to life elliptical orbit, of course elliptical orbits can be animated too should you go down that route.

Use a path / spline approach. The other methods are decent, but you will get a more realistic trajectory by using a spline/path. See this thread for an idea on how to do it:

But that sounds very cool!

Interesting approach, this is quite a good compromise, however I’d argue that you get a more realistic trajectory using the physics based approach although it would be much more expensive and time consuming to set-up.

Thank you all :slight_smile: It’s been a massive help to see the different directions to go about doing this. I think we’ve worked it out for now.