using UnityEngine;
using System.Collections;
public class Star : MonoBehaviour {
//是否公转
public bool isAround = false;
//自转速度
public float selfSpeed = 3f;
//公转速度
public float aroundSpeed = 3f;
//公转所绕的星星
public Transform point;
//公转所绕的轴
public Vector3 axis = new Vector3(0,1,0);
//星星外形
public Material mat;
//星星的大小
public Vector3 scale = new Vector3 (1, 1, 1);
void Start()
{
//设置星星的缩放
transform.localScale = scale;
//设置星星的外形(材质)
GetComponent<MeshRenderer> ().material = mat;
}
void Update()
{
//设置自转
transform.Rotate (new Vector3 (0,selfSpeed, 0));
//如果该星星有公转
if (isAround) {
//获取绕行点的坐标
Vector3 pt = point.position;
//公转
transform.RotateAround (pt, axis, aroundSpeed);
}
}
}
九大行星
最新推荐文章于 2021-02-24 13:26:57 发布