配列からPrefab化されているオブジェクトをランダムで選び、選ばれたPrefabをスクリーン上に呼び出すところまではできたのですが、Prefabを横にランダムに配置する方法が分かりません。
ご教授願います。
↓空のオブジェクトにアタッチしているスクリプト
c#
1using System.Collections; 2using System.Collections.Generic; 3using UnityEngine; 4 5public class RandomyasaiCreate : MonoBehaviour { 6 [SerializeField] 7 public GameObject[] yasai; 8 public GameObject yasaiCreate; 9 Rigidbody2D rb; 10 11 void Start () { 12 rb = GetComponent<Rigidbody2D>(); 13 StartCoroutine(YasaiCreate()); 14 } 15 16 IEnumerator YasaiCreate() { 17 while (true) { 18 int number = Random.Range (0, yasai.Length); 19 Instantiate (yasai [number], transform.position, transform.rotation); 20 yield return new WaitForSeconds (1.0f); 21 } 22 } 23} 24
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
退会済みユーザー
2018/07/23 11:21
2018/07/23 11:33
退会済みユーザー
2018/07/23 11:49