1.新建2个Sphere的GameObject,分别命名为Earth,Sun,顺便给个direct light也行。材质,贴图个人喜好了。
2.新建个脚本,并绑定至其中一个GameObject。内容如下:
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
using UnityEngine; namespace Assets.script { public class EarthCtrl : MonoBehaviour { private GameObject _earth; private GameObject _sun; private GameObject _mycamera; // Use this for initialization private void Start() { _sun = GameObject.Find("Sun"); _earth = GameObject.Find("Earth"); _mycamera = GameObject.Find("Main Camera"); } // Update is called once per frame private void Update() { _earth.transform.Rotate(Vector3.up); // 地球自转 _earth.transform.RotateAround(_sun.transform.position, Vector3.up, 1f); //地球围绕太阳转 _mycamera.transform.RotateAround(_sun.transform.position, Vector3.up, 0.1f); //相机,也就是我们围绕太阳转,但是总给人是太阳围绕我们转到错觉,好吧,地心说了 } } }