Unity_ Solar Moon Earth's rotation revolution script

Source: Internet
Author: User

/* 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
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.