]> git.lizzy.rs Git - SuperMouseAdventure.git/blobdiff - 2DGame/Assets/Scripts/Level_Elements/KeyScript.cs
key collecting v0.1
[SuperMouseAdventure.git] / 2DGame / Assets / Scripts / Level_Elements / KeyScript.cs
diff --git a/2DGame/Assets/Scripts/Level_Elements/KeyScript.cs b/2DGame/Assets/Scripts/Level_Elements/KeyScript.cs
new file mode 100644 (file)
index 0000000..16a23f6
--- /dev/null
@@ -0,0 +1,26 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+public class KeyScript : MonoBehaviour
+{
+    [SerializeField] private Transform bubblePos;
+    
+    bool collected;
+
+    private void OnTriggerEnter2D(Collider2D collision)
+    {
+        if (collision.gameObject.CompareTag("Player"))
+        {
+            collected = true;
+        }
+    }
+
+    private void Update()
+    {
+        if (collected)
+        {
+            transform.position = bubblePos.position;
+        }
+    }
+}