- Home /
 
 
               Question by 
               Reafy · Oct 08, 2014 at 12:04 AM · 
                regenerationhealth  
              
 
              Help With Health Regeneration
so this is my script to regenerate health but what i want it to do is wait 20 seconds then start regenerating. However if i just put another yield in there it waits 20.1 seconds the regenerates 2 health. So how would i make it start regeneration after 20 seconds
 function Regeneration () 
 {
     while (health < 100)
     {
         yield WaitForSeconds (0.1);
         health += 2;
     }
 }
 
              
               Comment
              
 
               
              Answer by BadAssGames · Oct 08, 2014 at 12:26 AM
 function Regeneration () 
 {
     yield WaitForSeconds(20.0f);
     while (health < 100)
     {
         yield WaitForSeconds (0.1);
         health += 2;
     }
 }
 
               Should work. I don't recall how Coroutines are done in js, but make sure you run it as a coroutine or your yields won't work right.
Your answer
 
             Follow this Question
Related Questions
Health Regeneration speeds up when action performed? 1 Answer
Regain health on GUI 2 Answers
C# Health regeneration delay after hit 0 Answers
How can i make my health regenerate? 1 Answer
regenerating health script 1 Answer