#pragma strict
var tex:GameObject[] = new GameObject[5];
var speed:int = 40;
function Start () {
for(var i:int =0 ; i {
var x;
var y;
//圆点坐标:(x0,y0)
//半径:r
//角度:a0
//则圆上任一点为:(x1,y1)
//x1 = x0 + r * cos(ao * 3.14 /180 )
//y1 = y0 + r * sin(ao * 3.14 /180 )
x= 0+ 3*Mathf.Cos(i*72 * 3.14/180);
y= 0+ 3*Mathf.Sin(i*72 * 3.14/180);
tex[i].transform.position = Vector3(x,0,y);
}
}
function Update () {
tex[0].transform.RotateAround(this.transform.position, Vector3.up, speed * Time.deltaTime);
tex[0].transform.LookAt(this.transform);
tex[1].transform.RotateAround(this.transform.position, Vector3.up, speed * Time.deltaTime);
tex[1].transform.LookAt(this.transform);
tex[2].transform.RotateAround(this.transform.position, Vector3.up, speed * Time.deltaTime);
tex[2].transform.LookAt(this.transform);
tex[3].transform.RotateAround(this.transform.position, Vector3.up, speed * Time.deltaTime);
tex[3].transform.LookAt(this.transform);
tex[4].transform.RotateAround(this.transform.position, Vector3.up, speed * Time.deltaTime);
tex[4].transform.LookAt(this.transform);
}
===============================================================
成果
物件就會對著設定的軸心(在這裡是空物件)做旋轉了。
沒有留言:
張貼留言