自转、公转脚本

自转

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);

}

}

你可能感兴趣的:(自转、公转脚本)