Heya. I’m new to unity (been using it for about a week) and have an issue with some code. This seems to make unity crash or just freeze up. I just want the current health variable to increase per second as long as you are “healthy”. Help is appreciated if its just that my code is not optimal.
var maxHealth : int = 1000;
var curHealth : int = 1000;
var healthy : boolean = true;
var nextActionTime : float = 0.0;
var period : float = 0.1;
while (healthy){
Heal();
}
function Heal(){
if (Time.time > nextActionTime ) {
nextActionTime += period;
if(curHealth < maxHealth){
curHealth += 1;
}
}
}