A Unity UPM package providing manual elliptical orbit control and automatic N-body gravity simulation for celestial bodies.
- Manual Orbit (
Orbit_manual) — Attach to any GameObject to drive elliptical orbits with configurable semi-major/minor axes, inclination, rotation, and starting angle. Supports Planet, Moon, and Comet self-rotation modes. Orbit path is visualized as a Gizmo in the Scene view. - Auto Gravity (
SolarSystemManager_auto) — Tag objects asCelestialand this manager computes N-body gravitational forces eachFixedUpdate, supporting both circular and elliptical initial velocities. - Sample Scenes — Importable sample scenes and test materials included.
- Unity 2021.3 or later
- Open Window → Package Manager
- Click the + button in the top-left corner
- Select Add package from git URL...
- Enter the following URL and click Add:
https://github.com/Shuaikx/Unity3D_CelestialOrbitSystem.git
To lock to a specific version, append a tag:
https://github.com/Shuaikx/Unity3D_CelestialOrbitSystem.git#v1.0.0
Open <YourProject>/Packages/manifest.json and add the following line inside "dependencies":
"com.shuaikx.celestialoritsystem": "https://github.com/Shuaikx/Unity3D_CelestialOrbitSystem.git"The package includes sample scenes and materials that are not imported automatically.
- Open Window → Package Manager
- Find Shuaikx CelestialOrbitSystem in the package list
- Select the Samples tab
- Click Import next to CelestialOrbitSystem
Samples will be copied to:
Assets/Samples/Shuaikx CelestialOrbitSystem/<version>/CelestialOrbitSystem/
- Add the
Orbit_manualcomponent to a GameObject (e.g., a planet mesh) - Assign an Orbit Center transform
- Set Semi Major Axis and Semi Minor Axis
- Enable Is Active to start the orbit
- Add the
SolarSystemManager_autocomponent to an empty GameObject in the scene - Tag all celestial bodies (sun, planets, moons) with the
Celestialtag - Ensure each celestial body has a
Rigidbodycomponent with appropriate mass values - Press Play — initial velocities are computed automatically
Packages/Shuaikx CelestialOrbitSystem/
└── Shuaikx_tools/
└── CelestialOrbitSystem/
└── Runtime/
├── Scripts/
│ ├── Orbit_manual.cs
│ └── SolarSystemManager_auto.cs
└── Shuaikx.CelestialOrbitSystem.Runtime.asmdef
Unity UPM 包,提供手动椭圆轨道控制和自动 N 体引力模拟功能。
- 手动轨道(
Orbit_manual) — 挂载到任意 GameObject,通过长轴/短轴、倾角、旋转角、起始角度等参数驱动椭圆轨道运动。支持行星、卫星、彗星三种自转模式,并在 Scene 视图以 Gizmo 可视化轨道路径。 - 自动引力(
SolarSystemManager_auto) — 将天体标记为CelestialTag,该管理器在每次FixedUpdate计算 N 体引力,支持圆形和椭圆形初始速度。 - 示例场景 — 包含可导入的示例场景和测试材质。
- Unity 2021.3 或更高版本
- 打开 Window → Package Manager
- 点击左上角 + 按钮
- 选择 Add package from git URL...
- 输入以下地址并点击 Add:
https://github.com/Shuaikx/Unity3D_CelestialOrbitSystem.git
如需锁定特定版本,在 URL 末尾加上标签:
https://github.com/Shuaikx/Unity3D_CelestialOrbitSystem.git#v1.0.0
打开目标项目的 <YourProject>/Packages/manifest.json,在 "dependencies" 中添加:
"com.shuaikx.celestialoritsystem": "https://github.com/Shuaikx/Unity3D_CelestialOrbitSystem.git"示例场景和材质不会自动导入,需手动操作:
- 打开 Window → Package Manager
- 在包列表中找到 Shuaikx CelestialOrbitSystem
- 切换到 Samples 选项卡
- 点击 CelestialOrbitSystem 旁边的 Import
导入后文件位于:
Assets/Samples/Shuaikx CelestialOrbitSystem/<版本号>/CelestialOrbitSystem/
- 将
Orbit_manual组件挂载到 GameObject(例如行星模型) - 指定一个 Orbit Center Transform 作为轨道中心
- 设置 Semi Major Axis(长轴)和 Semi Minor Axis(短轴)
- 勾选 Is Active 开始运行轨道
- 在场景中创建空 GameObject 并挂载
SolarSystemManager_auto组件 - 将所有天体(恒星、行星、卫星等)的 Tag 设为
Celestial - 确保每个天体都有
Rigidbody组件并设置合理的质量 - 点击 Play — 系统自动计算初始速度
Packages/Shuaikx CelestialOrbitSystem/
└── Shuaikx_tools/
└── CelestialOrbitSystem/
└── Runtime/
├── Scripts/
│ ├── Orbit_manual.cs
│ └── SolarSystemManager_auto.cs
└── Shuaikx.CelestialOrbitSystem.Runtime.asmdef