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.