October 2017
Intermediate to advanced
548 pages
13h 23m
English
Let's write a script called Orbit that rotates one object, the moon, around another object, the earth. We want to be able to specify its orbital period as the number of earth days for one complete orbit. For the moon, that's 27.3 days. And, like our Spin script, we'll also provide a scalar that converts earth days into game time seconds as shown ahead:
Write the Orbit class as follows:
File: Orbit.cs using System.Collections; using System.Collections.Generic; using UnityEngine; public class Orbit : MonoBehaviour { public Transform aroundBody; public ...Read now
Unlock full access