UNITY3D圆形算法

来源:互联网 发布:联想笔记本网络开关 编辑:程序博客网 时间:2024/06/07 13:05
using UnityEngine;using System.Collections;public class YScript : MonoBehaviour {public GameObject cm;private float angle=0;private float r=5;// Use this for initializationvoid 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 framevoid Update () {}}

0 0
原创粉丝点击