1、物体公转,即围绕一个中心物体旋转
public class gongzhuan : MonoBehaviour { public GameObject Axis;//轴,用于选择围绕中心 public float RotateSpeed;//旋转速度// Use this for initialization void Start () { } // Update is called once per frame void Update () { this.transform.RotateAround (Axis.transform.position, Vector3.up,RotateSpeed); } }将脚本拖动到物体上(此处为gongzhuan),同时选择围绕中心物体(此处为s),填写旋转速度。
2、物体自转,即以自己为中心旋转
public class zizhuan : MonoBehaviour { public float RotateSpeed;//旋转速度 // Use this for initialization void Start () { } // Update is called once per frame void Update () { transform.Rotate(Vector3.down* RotateSpeed,Space.World); } }将脚本拖动到物体上(此处为zizhuan),填写旋转速度。
转载于:https://www.cnblogs.com/hehaiyang/p/4333841.html
相关资源:3D自转公转.rar