#Unityで60個中の15個のGameObjectをランダムに当たり外れ分けさせる方法が分かりません。
ListやRandom.Langeを使うのは分かっているのですが、それをどう組み合わせるのかが分かりません。
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class ツリー : MonoBehaviour { public Text score; public int random; public int scoreint; public List <GameObject>l; // Use this for initialization void Start () { // //random = Random.Range (0, 1);ここが分かりません。 // } // Update is called once per frame void Update () { score.text = "プレゼントは今" + scoreint.ToString() + "個"; } void OnTriggerEnter(Collider col){ if(col.gameObject.CompareTag("Player")){ if(random == 1){ scoreint += 1; } Destroy (gameObject); } } }
#実現したいこと
プレイヤーが木にぶつかって、ランダムに外れだったらscoreintの数値は変えずに、当たりだったらscoreintを1増やす方法が分かりません。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/12/04 12:35
2018/12/04 14:37
2018/12/07 11:41