- Begin with an empty scene
- Create a GravityEngine (GameObject/3D Object/GravityEngine)
- Create a Star:
- Create an empty game object and name it “Star”
- Add an NBody component (Add Component/Scripts/NBody). Set the mass to 1000
- This script ensures the gravity engine controls this object. It provides the values for mass and initial velocity.
- The Transform component now changes to show only the position. Orbits in the gravity engine asset use hierarchy and this relies on a scale of 1 in the transform element.
- Create a model for the star (Game Objects/3D Object/Star)
- Make this a child of the Star with local position (0,0,0)
- Making the model a child allows the size of the Star to be adjusted without adversely impacting the scaling of other children.
- Add the Solar Texture as a Material
- Adjust the size to (5,5,5)
- Make this a child of the Star with local position (0,0,0)
- Create a planet (Repeat 3 and 4 naming the object “Planet”).
- Give the planet a mass of 5
- Add a material e.g. Ganymede from PATH_HERE
- Add an OrbitEllipse component to the Planet.
- This script defines orbital motion around a specified body. It will automatically select a parent object as this body.
- Make the planet a child of the Star.
- Look at OrbitEllipse in the Inspector and scene view
- Set the “Semi-Major Axis” to 10
- Experiment with the orbit attributes and observe how they change in the scene view.
- Press play to see the planet orbit the sun
- Can adjust the camera settings to see the orbit (z=-30)
- Change camera settings to a background with a solid color if you wish.
- Create an empty game object “DustRing”
- Add a particle system
- Duration=999
- Start lifetime=999
- Start Speed=0
- Emission Rate=0
- Emit as a burst of 1000 at time=0
- Add a GravityParticles script to DustRing object.
- This script indicates the Gravity Engine will control the particles.
- Add a DustRing script to DustRing object. This controls the initial position and velocity of the particles.
- Add a material (e.g. BlueMat at PATH)
- Adjust the orbit to the desired size and shape.
- Make the DustRing object a child of the star.
- Press play to see the dust ring and planet.