Files
PuzzleColorBall/Assets/Scripts/CollectCoin.cs
2023-02-27 12:09:47 +01:00

20 lines
421 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CollectCoin : MonoBehaviour
{
private CoinCounter counter;
private void Awake() {
counter = FindObjectOfType<CoinCounter>();
}
private void OnTriggerEnter(Collider other) {
if(other.gameObject.tag == "Player"){
counter.AddCoin(1);
Destroy(gameObject);
}
}
}