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()
{
// 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);
}
}