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

unity3d 在一个空心圆范围内随机生成物体

2015-02-07 19:28 295 查看
using UnityEngine;
using System.Collections;

public class RandomRadius : MonoBehaviour {
public GameObject prefabs;
// Use this for initialization
void Start () {
for (int i = 0; i < 1000; i++) {
Vector2 p = Random.insideUnitCircle*3;
Vector2 pos = p.normalized*(2+p.magnitude);
Vector3 pos2 = new Vector3(pos.x,0,pos.y);
Instantiate(prefabs,pos2,Quaternion.identity);
}
}

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

}
}





只在红色区域内生成

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