C#
1using System.Collections; 2using System.Collections.Generic; 3using UnityEngine; 4using UnityEngine.UI; 5 6public class ScorebelowController : MonoBehaviour { 7 public Text scoreText; 8 private int score = 0; 9 10 void Start() { 11 score = 0; 12 SetScore(); 13 } 14 15 void OnCollisionEnter(Collision other) { 16 if(other.gameObject.tag == "player") { 17 score += 10; 18 } else { 19 score -= 10; 20 } 21 SetScore(); 22 } 23 24 void SetScore() { 25 scoreText.text = string.Format("{0}", score); 26 } 27} 28
上記のスクリプトで"player"というタグのオブジェクトに当たったらスコアを+10点、それ以外のオブジェクトに当たると-10点と書きました。
しかし、スコアが増加されません。
ご教授願います。
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。