Orbit and Gravity Movement Blueprint

You could have a moon that is orbiting a planet, while a planet is orbiting a sun. There are two types of physics modes and the behavior will be different depending on which ones you choose.

In Kinematic mode, gravity is calculated each frame (or more frequently if you use substepping). In this mode, multiple GravityMasses can affect an object that has an OrbitMovementComponent. So a moon can be affected by both its planet;s GravityMass and the sun’s GravityMass. Gravity is calculated in real time, so you could drop another planet into the scene and it would affect the other actors (but you would need to call the function “AddAllGravityMassesInScene” from each OrbitMovement component in order to register the new GravityMass with the orbit component). The downside of this mode is that the physics is calculated at a timestep (like the framerate), and accuracy is directly related to how frequently the physics runs. Orbits in this mode could also become unstable due to variations in how often physics is calculated, or if multiple gravityMasses affect an orbit enough to pull the object out of orbit.

In Kepler mode, a “perfect” orbit is calculated based on two actors only. This orbit will never change and will not become unstable (unless you tell it to change). This mode will keep the same orbit regardless of framerate. In this mode, you would add a planet and set it to orbit the sun, and then add a moon and set it to orbit the planet. The moon will orbit the planet while the planet orbits the sun, but the sun’s gravity won’t be affecting the moon like in kinematic mode. The advantages for this mode is that the orbit is a mathematically ‘perfect’ orbit that will not change based on framerate or physics substepping rate. The downside is that this will only calculate gravity from one GravityMass at a time.