CoinCollider.cs 721 B

1234567891011121314151617181920212223242526272829303132
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class CoinCollider : MonoBehaviour
  5. {
  6. // Start is called before the first frame update
  7. void Start()
  8. {
  9. }
  10. // Update is called once per frame
  11. void Update()
  12. {
  13. }
  14. void OnCollisionEnter(Collision collision) {
  15. Debug.Log("Hit Coin");
  16. }
  17. void OnTriggerEnter(Collider collision) {
  18. Debug.Log("Hit Coin");
  19. var kind = collision.gameObject;
  20. // Only consider collision if it's with player
  21. //if (kind.tag == "bike") {
  22. kind.GetComponent<PlayerStats>().hitCounter += 1;
  23. Destroy(gameObject); // Destroy Coin
  24. //}
  25. }
  26. }