Question by 
               Life01 · Feb 05 at 01:28 PM · 
                scripting problembugscripting beginnerbug-perhaps  
              
 
              Taking continuously damage on a surface
Hello, here is my code right here:
 private void OnCollisionStay2D(Collision2D other)
 {
     if(!invincible)
     {
         if (other.gameObject.CompareTag("Player"))
         {
             HealthBar.health -= 20f;
             StartCoroutine(Invulnerability());
         }
     }
     
 }
 IEnumerator Invulnerability()
 {
     invincible = true;
     yield return new WaitForSeconds(invincibilityTime);
     invincible = false;
 }
 
And here's my problem:
I have some spikes that if you stay on you take damage, and I added an invincibility time so you are 1 second invincible from them. It works fine but after that 1 second the player wont take damage even if he stays on them, unless he moves on the spikes, any help? I want to take damage constantly even if I don't move..
               Comment
              
 
               
              Your answer
 
 
             Follow this Question
Related Questions
How do I fix my UnityEngine Reference? 1 Answer
CAMERAS ERROR , I NEED HELP 0 Answers
Unity {[(2D)]} RotateAround while jumping 0 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
               
 
			 
                