|
@@ -0,0 +1,32 @@
|
|
|
+using System.Collections;
|
|
|
+using System.Collections.Generic;
|
|
|
+using UnityEngine;
|
|
|
+
|
|
|
+public class CoinCollection : MonoBehaviour
|
|
|
+{
|
|
|
+ // Start is called before the first frame update
|
|
|
+ void Start()
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ // 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<PlayerStats>().IncreaseCoinCounter();
|
|
|
+ Destroy(gameObject);
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|