/* Title: ""
* Function:
*-Sun rotation
*-Earth Rotation, revolution
*-Moon Rotation, revolution
* Used by:
* Author:ys.
* date:2016.12.
* version:1.0
* Description (Record):
*
************************/
Using Unityengine;
Using System.Collections;
public class Sunearthmoon:monobehaviour
{
Public Transform Trsun; Definition Sun
Public Gameobject GoSun;
Public Transform Trearth; Define the Earth
Public Transform Trmoon; Defining the Moon
public float flrotaspeedself; Rotation speed
public float Flrotaspeedcommearth; The speed of the Earth's revolution
public float Flrotaspeedcommmoon; The speed of the lunar revolution
void Start ()
{
}//end_start
void Update ()
{
The rotation of the sun
The script hangs to who, lets who turn
This.gameObject.transform.Rotate ();
Transform. Rotate ();
After the script is hung, which object is dragged to Trsun?
Trsun.rotate (Vector3.up * flrotaspeedself);
Because the component name is not the same, if you want to use another component name, you must first "." Come out
GoSun.transform.Rotate ();
Rotation of the Earth
Trearth.rotate (Vector3.up * flrotaspeedself);
The Revolution of the Earth
Trearth.rotatearound (Trsun.position,vector3.up, Flrotaspeedcommearth);
The rotation of the moon
Trmoon.rotate (Vector3.up * flrotaspeedself);
The Moon's revolution
Trmoon.rotatearound (Trearth.position,vector3.up,flrotaspeedcommmoon);
}//end_update
}