Solar System
An n-body gravity simulation in C++ for Unreal Engine, with a tool that predicts orbits in the editor and a tutorial to rebuild it.
Facts
- Personal project, 2024 · Open Source (MIT)
- Orbit debugger with fourth-order Runge-Kutta, without Play mode
- Tutorial in German and English
What it's about
I wanted to create a very well documented way to rebuild an n-body simulation without much prior knowledge. So the project is a simulation and a tutorial at once. The idea came from Sebastian Lague and the game Outer Wilds.
The tutorial is in German and English and goes from an empty Unreal project to a running solar system: class design, the derivation of the gravity formula, materials and post-processing. It comes with the values of the real solar system: sizes from the planets' diameters, distances converted from astronomical units to Unreal units, masses relative to Earth.
How it works
Every body pulls on every other; there is no fixed central star. New bodies register themselves, and their mass follows from their radius.
The orbit debugger runs its prediction on copies of the bodies with the fourth-order Runge-Kutta method and draws the orbits in the editor, without pressing Play. That way you can tune whether an orbit closes without starting the simulation again and again. An editor plugin of my own puts it into a window with toggles and input fields.
Where it stands
Concluded.