using System.Collections; using System.Collections.Generic; using UnityEngine; using Pools; public class CoinCollection : MonoBehaviour { public CoinPool coinPool; public CoinCreation spawn; // Start is called before the first frame update void Start() { coinPool = GameObject.FindGameObjectWithTag("CoinPool").GetComponent(); } // Update is called once per frame void Update() { } //Keep count of collisions with player private void OnTriggerEnter(Collider other) { Debug.Log("Coin Hit!"); if (other.gameObject.CompareTag("bike")) { Debug.Log("Collecting Coin"); // Increase Hit Counter var bike = other.gameObject; bike.GetComponent().IncreaseCoinCounter(); coinPool.ReturnToPool(gameObject); } } }