Simple Kepler Orbits by Karth42 - 1

Games & ProjectsSDK

Unity3d static 2-body orbits simulation

Unity 2019.4.8f1MIT LicenseUpdated 55 days agoCreated on August 12th, 2017
Go to source

SimpleKeplerOrbits

gif

Description

Unity3d project for simulating simple orbits using 2-body solution model.

Importing

This repository contains the entire Unity Project for basic demo setup. There are several ways to import the project:

  • Manually copy all files from Asset directory to your unity project directory;
  • Import asset store package;
  • Import of the ‘src’ branch as submodule, which contains only Assets folder content.

Usage

This plugin has the ability to customize orbits using the editor inspector and scripts. Some scripting usage examples:

Initializing orbit from orbit elements (JPL database supported)

	var body = GetComponent<KeplerOrbitMover>();
	body.AttractorSettings.AttractorObject = attractorTransform;
	body.AttractorSettings.AttractorMass = attractorMass;
	body.AttractorSettings.GravityConstant = GConstant;
	body.OrbitData = new KeplerOrbitData(
		eccentricity: eValue,
		semiMajorAxis: aValue,
		meanAnomalyDeg: mValue,
		inclinationDeg: inValue,
		argOfPerifocus: wValue,
		ascendingNodeDeg: omValue,
		attractorMass: attractorMass,
		gConst: GConstant);
	body.ForceUpdateViewFromInternalState();

Initializing orbit from orbit vectors

	var body = GetComponent<KeplerOrbitMover>();
	body.AttractorSettings.AttractorObject = attractorTransform;
	body.AttractorSettings.AttractorMass = attractorMass;
	body.AttractorSettings.GravityConstant = GConstant;
	body.OrbitData = new KeplerOrbitData(
		position: bodyPosition, 
		velocity: bodyVelocity, 
		attractorMass: attractorMass, 
		gConst: GConstant);
	body.ForceUpdateViewFromInternalState();

For more detailed scripting snippets go to the included manual.

Contributing

This repository is closed for contributions.

Published version

Unity Asset Store

License

MIT

Show all projects by Karth42