using System.Collections; using System.Collections.Generic; using UnityEngine; public class CoinCollider : MonoBehaviour { // Start is called before the first frame update void Start() { } // Update is called once per frame void Update() { } void OnCollisionEnter(Collision collision) { Debug.Log("Hit Coin"); } void OnTriggerEnter(Collider collision) { Debug.Log("Hit Coin"); var kind = collision.gameObject; // Only consider collision if it's with player //if (kind.tag == "bike") { kind.GetComponent().hitCounter += 1; Destroy(gameObject); // Destroy Coin //} } }