首先创建一个太阳以及9大行星(虽然现在好像是8大了,但是我就按照还是比较早先的说法九大行星吧)。
好的然后我们就给他们分别挂载行为脚本就好。
using System.Collections; using System.Collections.Generic; using UnityEngine; public class run : MonoBehaviour { public float speed = 10; float rotateY, rotateZ; // Use this for initialization void Start () { rotateY = Random.Range (1, 180); rotateZ = Random.Range (1, 180); } // Update is called once per frame void Update () { Vector3 axis = new Vector3 (0, rotateY, rotateZ); this.transform.RotateAround (new Vector3(0,0,0), axis, speed * Time.deltaTime); } }speed设为public其实我们也可以在inspector中进行修改,方便调试。
这个轨迹可能太挫了,轨迹我是使用trail renderer 这个组件。本身它是来实现拖尾效果的,不过简单的轨迹就当然也可以。 稍稍修改了一下。