Files
PuzzleColorBall/Assets/Scripts/CollectCoin.cs

20 lines
421 B
C#
Raw Normal View History

2023-02-27 12:09:47 +01:00
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);
}
}
}