Unityでりんごが落ちてくるゲームを作っています
アイテムを2つまでは落とせるようになったのですが3つ目のアイテムをどうすれば落とせるのかがわかりません
どうすれば3つ目4つ目と落とすアイテムを増やせるでしょうか?
C#
1using System.Collections; 2using System.Collections.Generic; 3using UnityEngine; 4 5public class ItemGen : MonoBehaviour{ 6 public GameObject applePrefab; 7 public GameObject bombPrefab; 8 float span = 0.5f; 9 float delta = 0; 10 int ratio = 3; 11 // Update is called once per frame 12 void Update(){ 13 this.delta += Time.deltaTime; 14 if (this.delta > this.span) { 15 this.delta = 0; 16 GameObject item; 17 int dice = Random.Range (1, 11); 18 if (dice <= this.ratio) { 19 item = Instantiate (bombPrefab) as GameObject; 20 } else { 21 item = Instantiate (applePrefab) as GameObject; 22 } 23 float x = Random.Range (-1, 2); 24 float z = Random.Range (-1, 2); 25 item.transform.position = new Vector3 (x, 4, z); 26 } 27 } 28}
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/03/30 06:16