自转
public class StarRotation : MonoBehaviour {
public float speed;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
transform.Rotate (new Vector3 (0f,1f,0f)*Time.deltaTime*speed);
}
}
公转
public class Revolution: MonoBehaviour {
public Transform tragetTransform;
public float angleSpeed;//外联值在初始化和Awake之间起作用
void Start () {
}
void Update () {
transform.RotateAround (tragetTransform.position, new Vector3 (0f, 1f, 0f), angleSpeed * Time.deltaTime);
}
}