1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
using System.Collections; using System.Collections.Generic; using UnityEngine; public class Clone : MonoBehaviour { [SerializeField] GameObject prefab; int count = 0; int max = 50; void Start() { InvokeRepeating("Generate", 1, 1); } void Generate() { if (count == max) return; float x = Random.Range(0f, 500f); float y = 0; float z = Random.Range(0f, 500f); Vector3 position = new Vector3(x, y, z); Instantiate(prefab, new Vector3(x, y, z), Quaternion.identity); count++; } } |
ランダムな場所にクローン生成
投稿日:
執筆者:getabako
[…] ランダムな場所にクローン生成 […]
毎度お馴染みユニティヤングです(何度もすみません。プログラミングが好きなんです(汗))
今、このプログラムを使って地面をランダムな位置に複製しているのですが、1秒ずつだと生成が間に合いません。一瞬で生成する方法はないですか?ちょっといじってみたのですが全く分からなくて。