using UnityEngine;
using System.Collections;
public class CreateGameObject : MonoBehaviour {
private Vector3 centerPos;
private float radius = 5;
private float angle = 0;
public GameObject cube;
void Start () {
CreateMosquitoCoil ();
}
public void CreateCubeAngle30()
{
centerPos = transform.position;
for (angle = 0; angle < 360; angle+=30) {
float x = centerPos.x + radius * Mathf.Cos (angle * 3.14f / 180f);
float y = centerPos.y + radius * Mathf.Sin (angle * 3.14f / 180f);
GameObject obj = (GameObject)GameObject.Instantiate (cube, new Vector3 (x, y, centerPos.z), Quaternion.identity);
}
}
public void CreateMosquitoCoil()
{
centerPos = transform.position;
for (int i = 0; i < 30; angle+=20,radius+=0.3f,i++) {
float x = centerPos.x + radius * Mathf.Cos (angle * 3.14f / 180f);
float y = centerPos.y + radius * Mathf.Sin (angle * 3.14f / 180f);
GameObject obj = (GameObject)GameObject.Instantiate (cube, new Vector3 (x, y, centerPos.z), Quaternion.identity);
}
}
}
|