Hi,
I would like to have multiple objects with a variation of different “scores/points”, for an example, one coin is worth 1 point and another is worth 20. How would I go about implementing this? This is the code I have so far;
public class CoinScript : MonoBehaviour
{
public GameHandler GH;
public AudioClip coinSound;
// Start is called before the first frame update
void Start()
{
GH = GameObject.Find("Canvas").GetComponent<GameHandler>();
}
private void OnTriggerEnter(Collider other)
{
GH.coins++;
AudioSource.PlayClipAtPoint(coinSound, transform.position);
Destroy(gameObject);
}
Second Script;
public class GameHandler : MonoBehaviour
{
public TextMeshProUGUI CoinText;
public int coins = 0;
private void Update()
{
CoinText.text = "Coins Collected : 0 " + coins;
}
}