Launch Mini-Game

Version 1.6 includes a “mini-game” to demonstrate the rocket engine component and its use in a scenario where a multi-stage rocket launches from the surface of Earth into orbit.

A quick demonstration of these is provided in the video below:

The goal of the mini-game is to provide a framework for scenes that require a launch to orbit and show how the various elements in Gravity Engine can be combined to make this happen. The scene models launch from the surface of the Earth making use of ORBITAL units. This sets a scale of 1km per Unity unit. The scene takes some liberty with the scale of the rocket and it’s stages and dynamically scales the model and paths in the scene based on whether the ship camera or orbit camera is being used.

The rocket is powered by the MultiStageEngine script. This allows up to 10 stages to be specified in the inspector with mass/thrust/burn rate in SI units. The script also allows an optional Effect Object to be activated when the stage engine is on allowing control of e.g. particle systems to show exhaust.

Once the ship is under thrust the projected path of the object is shown as a trajectory. This trajectory incorporates the continued thrust of the stage up to the point where its fuel is exhausted. The gravity engine class is aware of the rocket engine classes attached to massless bodies in the scene and applies thrust in every integration time step. This is the most realistic way to model the flight under power.

Design of the Mini-Game

The scene implementation is based on a game controller class model using the LaunchUI script. The game controller loop handles:

  1. User interface state
  2. Ship maneuver commands
  3. Start engine/stage engine
  4. Automatically stage engine when fuel is exhausted.
  5. Selection of ship camera or Earth view camera via F1/F2 and re-scaling some elements in the scene as the camera is changed (using the LineScalar class as a helper)

Additional user interaction is handled in two other scripts:

  • CameraSpin: Handles camera orientation and zoom via keys and mouse (and scales LineRenderers in the scene during zoom via the LineScalar class)
  • TimeZoom: Adjust scene play speed as 1-5 are pressed

Dynamic position/velocity information is provided by the ShipInfo script.

Orbit information is presented by the OrbitParamPanel script after the rocket reaches an altitude of 50km.

There is more to do…

There are several physics elements that are needed to make the simulation more accurate:

  1. Take account of the rotation of the Earth and its impact on the ship initial velocity.
  2. Add atmospheric drag as a function of velocity and atmosphere density profile.

These are on the Trello board. If you want to nudge them up the list, send an email to nbodyphysics@gmail.com.