Skip to content

Instantly share code, notes, and snippets.

@kaorun55
Created May 18, 2016 16:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kaorun55/7f729b3b79ef53f0ab4871eedd600a96 to your computer and use it in GitHub Desktop.
Save kaorun55/7f729b3b79ef53f0ab4871eedd600a96 to your computer and use it in GitHub Desktop.
using UnityEngine;
using System.Collections;
public class CubeCreator : MonoBehaviour
{
public GameObject cubePrefab;
// Use this for initialization
void Start()
{
StartCoroutine(CreateCube());
}
private IEnumerator CreateCube()
{
while (true)
{
// カメラの正面から落とす
float r = 1.5f;
var theta = transform.rotation.eulerAngles.y * Mathf.Deg2Rad;
var x = r * Mathf.Sin(theta);
var z = r * Mathf.Cos(theta);
Instantiate(cubePrefab,
new Vector3(x, 1, z),
Quaternion.Euler(0, transform.rotation.eulerAngles.y, z));
yield return new WaitForSeconds(1);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment