您的位置:首页 > 移动开发 > Unity3D

UNITY3D圆形算法

2016-06-14 02:43 441 查看
using UnityEngine;
using System.Collections;

public class YScript : MonoBehaviour {
public GameObject cm;
private float angle=0;
private float r=5;
// Use this for initialization
void Start () {
Vector3 center = new Vector3(0,0,0);
for (int i=0; i<36; i++) {

GameObject cube= GameObject.CreatePrimitive(PrimitiveType.Cube);
float hudu=(angle/180)*Mathf.PI;
float xx=center.x+r*Mathf.Sin(hudu);
float yy=center.y+r*Mathf.Cos(hudu);
cube.transform.position=new Vector3(xx,yy,0);

cube.transform.LookAt(cm.transform.position);

angle+=10;
}
}

// Update is called once per frame
void Update () {

}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: