Finished tutorial
This commit is contained in:
@@ -1,14 +1,29 @@
|
||||
using UnityEngine;
|
||||
using TMPro;
|
||||
|
||||
public class Scorer : MonoBehaviour
|
||||
{
|
||||
[SerializeField] TextMeshProUGUI scoreText;
|
||||
[SerializeField] int maxHits;
|
||||
int hits = 0;
|
||||
void Start()
|
||||
{
|
||||
hits = 0;
|
||||
scoreText.text = "Hits: " + hits.ToString();
|
||||
}
|
||||
private void OnCollisionEnter(Collision other)
|
||||
{
|
||||
if (other.gameObject.tag != "Hit")
|
||||
{
|
||||
if (hits < maxHits)
|
||||
{
|
||||
hits++;
|
||||
Debug.Log("You've bumped into something this many times: " + hits);
|
||||
scoreText.text = "Hits: " + hits.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user