Tutorial 1 – Binary Stars


  1. Create an GravityEngine (GameObject/3D Object/GravityEngine)
  2. Move two copies of the Star prefab into the scene
    1. Place them at X=-10 and X =10
  3. Press PLAY and observe
    1. The gravity engine moves the objects and they go through each other and fly apart. This is due to a numerical breakdown when they get very close and the forces become large. In most cases a collision handler would intervene.
    2. There is an alternative algorithm that is less vulnerable to this. It can be found under the GravityEngine/Advanced section in the inspector. Select HERMITE8 and see what happens. (Hermite adapts the time step and does a better job with large forces when objects get close. It used more CPU than LEAPFROG but does a better job of conserving energy).
  4. Create an orbiting pair by setting the Y velocity of the NBody component of one star to +4 and the other to -4.
    1. PLAY now shows these objects in orbit around each other as a binary pair.
    2. Getting a specific orbit by setting the velocity is challenging
  5. Create an empty game object “BinaryPair”
    1. Attach the Script “BinaryPair”
    2. Make each Star a child of the binary pair
    3. Set the size (semi-major axis) of the ellipse to 20. Now the inspector shows BOTH orbits and they can be adjusted.
    4. Make one of the stars a different mass – notice how the orbits are adjusted.
  6. The game speed of the binary star evolution can be controlled in several ways:
    1. The mass of each star could be scaled. Larger mass values result in larger forces and faster motion.
    2. The mass scale of the entire scene is controlled by the Gravity Engine. In the Scaling section of the GravityEngine the overall mass scale can be adjusted with the ‘mass scale’ parameter. Increasing the mass scale will make everything move faster. Velocities will also be adjusted so the same motion results – just faster.
    3. GravityEngine also allows control of the timescale. This changes the motion speed but by doing more physics calculations each frame.