]> git.lizzy.rs Git - SuperMouseAdventure.git/blobdiff - 2DGame/Assets/Scripts/Maus/InvincibilityFrames.cs
Invincibility Frames v0.1
[SuperMouseAdventure.git] / 2DGame / Assets / Scripts / Maus / InvincibilityFrames.cs
index f5484e0ef84cf13eabe02a8f8aa62b83c9705283..c1618f72166be5b200783a412c7bdd93c9cc6e96 100644 (file)
@@ -5,9 +5,13 @@ using UnityEngine;
 public class InvincibilityFrames : MonoBehaviour
 {
     SpriteRenderer spriteRenderer;
-
     Health health;
 
+    public bool invincible;
+
+    public float invincibilityFramesNumber = 2;
+    private float invincibilityFrames;
+
     // Start is called before the first frame update
     void Start()
     {
@@ -18,9 +22,20 @@ public class InvincibilityFrames : MonoBehaviour
     // Update is called once per frame
     void Update()
     {
-        if(health.invincible == true)
+        if(invincible == true)
         {
-
+            invincibilityFrames = invincibilityFramesNumber;
+            invincibilityFrames -= Time.deltaTime;
+            if(invincibilityFrames > 0)
+            {
+                invincible = true;
+            }
+            if (invincibilityFrames == 0)
+            {
+                invincible = false;
+            }
         }
+
+        print(invincible);
     }
 }