Skip to content

Repository files navigation

Shuaikx CelestialOrbitSystem

A Unity UPM package providing manual elliptical orbit control and automatic N-body gravity simulation for celestial bodies.

中文文档


Features

  • 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 as Celestial and this manager computes N-body gravitational forces each FixedUpdate, supporting both circular and elliptical initial velocities.
  • Sample Scenes — Importable sample scenes and test materials included.

Requirements

  • Unity 2021.3 or later

Installation

Via Unity Package Manager (Git URL) — Recommended

  1. Open Window → Package Manager
  2. Click the + button in the top-left corner
  3. Select Add package from git URL...
  4. 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

Manual Installation via manifest.json

Open <YourProject>/Packages/manifest.json and add the following line inside "dependencies":

"com.shuaikx.celestialoritsystem": "https://github.com/Shuaikx/Unity3D_CelestialOrbitSystem.git"

Importing Samples

The package includes sample scenes and materials that are not imported automatically.

  1. Open Window → Package Manager
  2. Find Shuaikx CelestialOrbitSystem in the package list
  3. Select the Samples tab
  4. Click Import next to CelestialOrbitSystem

Samples will be copied to:

Assets/Samples/Shuaikx CelestialOrbitSystem/<version>/CelestialOrbitSystem/

Quick Start

Manual Orbit

  1. Add the Orbit_manual component to a GameObject (e.g., a planet mesh)
  2. Assign an Orbit Center transform
  3. Set Semi Major Axis and Semi Minor Axis
  4. Enable Is Active to start the orbit

Auto Gravity

  1. Add the SolarSystemManager_auto component to an empty GameObject in the scene
  2. Tag all celestial bodies (sun, planets, moons) with the Celestial tag
  3. Ensure each celestial body has a Rigidbody component with appropriate mass values
  4. Press Play — initial velocities are computed automatically

Package Contents

Packages/Shuaikx CelestialOrbitSystem/
└── Shuaikx_tools/
    └── CelestialOrbitSystem/
        └── Runtime/
            ├── Scripts/
            │   ├── Orbit_manual.cs
            │   └── SolarSystemManager_auto.cs
            └── Shuaikx.CelestialOrbitSystem.Runtime.asmdef


中文文档

Unity UPM 包,提供手动椭圆轨道控制和自动 N 体引力模拟功能。

Back to English


功能

  • 手动轨道(Orbit_manual — 挂载到任意 GameObject,通过长轴/短轴、倾角、旋转角、起始角度等参数驱动椭圆轨道运动。支持行星、卫星、彗星三种自转模式,并在 Scene 视图以 Gizmo 可视化轨道路径。
  • 自动引力(SolarSystemManager_auto — 将天体标记为 Celestial Tag,该管理器在每次 FixedUpdate 计算 N 体引力,支持圆形和椭圆形初始速度。
  • 示例场景 — 包含可导入的示例场景和测试材质。

环境要求

  • Unity 2021.3 或更高版本

安装方法

通过 Unity Package Manager(Git URL)— 推荐

  1. 打开 Window → Package Manager
  2. 点击左上角 + 按钮
  3. 选择 Add package from git URL...
  4. 输入以下地址并点击 Add
https://github.com/Shuaikx/Unity3D_CelestialOrbitSystem.git

如需锁定特定版本,在 URL 末尾加上标签:

https://github.com/Shuaikx/Unity3D_CelestialOrbitSystem.git#v1.0.0

手动编辑 manifest.json

打开目标项目的 <YourProject>/Packages/manifest.json,在 "dependencies" 中添加:

"com.shuaikx.celestialoritsystem": "https://github.com/Shuaikx/Unity3D_CelestialOrbitSystem.git"

导入示例

示例场景和材质不会自动导入,需手动操作:

  1. 打开 Window → Package Manager
  2. 在包列表中找到 Shuaikx CelestialOrbitSystem
  3. 切换到 Samples 选项卡
  4. 点击 CelestialOrbitSystem 旁边的 Import

导入后文件位于:

Assets/Samples/Shuaikx CelestialOrbitSystem/<版本号>/CelestialOrbitSystem/

快速上手

手动轨道

  1. Orbit_manual 组件挂载到 GameObject(例如行星模型)
  2. 指定一个 Orbit Center Transform 作为轨道中心
  3. 设置 Semi Major Axis(长轴)和 Semi Minor Axis(短轴)
  4. 勾选 Is Active 开始运行轨道

自动引力

  1. 在场景中创建空 GameObject 并挂载 SolarSystemManager_auto 组件
  2. 将所有天体(恒星、行星、卫星等)的 Tag 设为 Celestial
  3. 确保每个天体都有 Rigidbody 组件并设置合理的质量
  4. 点击 Play — 系统自动计算初始速度

包内容结构

Packages/Shuaikx CelestialOrbitSystem/
└── Shuaikx_tools/
    └── CelestialOrbitSystem/
        └── Runtime/
            ├── Scripts/
            │   ├── Orbit_manual.cs
            │   └── SolarSystemManager_auto.cs
            └── Shuaikx.CelestialOrbitSystem.Runtime.asmdef

About

A Unity UPM package providing manual elliptical orbit control and automatic N-body gravity simulation for celestial bodies.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages