(chapter Fourth) unity3d-Earth Rotation Dome

Source: Internet
Author: User

Bo Master Nothing to write a very simple doem on a few lines of code.

Is that the earth goes around the sun.

First create two spheres, respectively, set the corresponding size, named Sun,earth.

Then create a C # script to write code.

Using Unityengine;
Using System.Collections;
 
public class Earthctrl:monobehaviour {
 
//Declare game object
private Gameobject M_gosun;
Private Gameobject M_goearth;
 
Use
the This for initialization void Start () {
//Get Object
m_gosun=gameobject.find ("Sun");
M_goearth=gameobject.find ("Earth");
}
Update is called once per frame
void Update () {
/
 * * public void Rotatearound (Vector3 point, Vector3 a XIs, float angle)
 * point: To revolve around the points, axis: the direction around, angle: the angle of rotation.
 *
/M_GOEarth.transform.RotateAround (m_gosun.transform.position,vector3.up,1.0f);
}
}


Gameobject: is the base class for all entities within the unity scene, and the game object is a container for all other components. All objects in your game are objects of the game. The next chapter introduces Gameobject

Find: Finds and returns a game object named name.

Rotatearound: Revolve around an object

Point: To revolve around the points, axis: the direction around, angle: the angle of rotation.

The transform component is used to control the position, rotation and scaling of the object, which involves two emphases, one is the coordinate system, this includes the relationship between the local coordinate system and the world coordinate system, the other is the parent-child node, and the Gameobject parent-child node relationship is maintained by the transform component.

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.