Skip to content

About

A real-time simulation of planets, moons, and orbital mechanics using Newtonian physics and N-body gravitational interactions.

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Latest commit

 

History

17 Commits

Folders and files

Repository files navigation

Physics-Based Solar System Simulation

Solar System Preview

A real-time N-body gravitational simulation built in Unity, designed to model orbital mechanics using classical Newtonian physics.


Overview

This project implements a multi-body physics solver to simulate the gravitational interactions between planets, moons, and custom celestial bodies. Rather than relying on hardcoded circular paths, bodies move and interact based on continuous force calculations.

The simulation handles:

  • Mutual Gravitational Forces: Computes real-time $N$-body interactions between all active bodies in the scene.
  • Euler Integration: Updates positions and velocities dynamically across physics timesteps.
  • Orbit Prediction: Renders projected trajectories ahead of time using a LineRenderer.
  • Configurable Parameters: Allows tweaking mass, radius, initial velocity, and hierarchy setups (like moons inheriting parent velocities).

Features

Core Simulation

  • Gravitational Solver: Applies Newton's law of universal gravitation across every active body per frame.
  • Time Scaling: Adjust the timeScale parameter at runtime to speed up or slow down the simulation.
  • Lightweight Architecture: Runs natively in both the Unity Editor and final builds without external dependencies.

Orbit Line Prediction

  • Computes multi-step lookaheads to draw predicted paths.
  • Toggle between highlighting individual body previews or rendering all orbits simultaneously.
  • Custom color tinting for orbit trails to keep complex systems readable.

Example Scenes

Solar System

Full solar system simulation with planets and orbit prediction.
Solar System Video

Two Moons

Real-time simulation of a planet with two moons showing gravitational interactions.
Two Moons Video

Mercury Precession

Demonstrates precession of Mercury's orbit due to gravitational perturbations.
Mercury Precession Video

About

A real-time simulation of planets, moons, and orbital mechanics using Newtonian physics and N-body gravitational interactions.

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages