自轉
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);
}
}