Created
May 18, 2016 16:05
-
-
Save kaorun55/7f729b3b79ef53f0ab4871eedd600a96 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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