Browse Source

Add Coin Script

Till Steinert 2 years ago
parent
commit
27de1f53d6

+ 7 - 0
Assets/Coin/Coin.prefab.meta

@@ -0,0 +1,7 @@
+fileFormatVersion: 2
+guid: 8245067f1320d57fbb2d50aff07977b8
+PrefabImporter:
+  externalObjects: {}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 32 - 0
Assets/Coin/CoinCollection.cs

@@ -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);
+        }
+    }
+}

+ 11 - 0
Assets/Coin/CoinCollection.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: db54fa6c98d9a61898f79796237ddfdf
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 8 - 0
Assets/Coin/CoinMaterial.mat.meta

@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: f58fcb8ec1c61da7697ad4a0107338da
+NativeFormatImporter:
+  externalObjects: {}
+  mainObjectFileID: 0
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: