Lets say this is my script:
var On : boolean = false;
var Off : boolean = true;’
var Health : float = 20;
function Update()
{
if(On == true)
{
HealthOn()
}
}
function HealthOn()
{
Health -= 2
//yield for 3 seconds
}
Lets say this is my script:
var On : boolean = false;
var Off : boolean = true;’
var Health : float = 20;
function Update()
{
if(On == true)
{
HealthOn()
}
}
function HealthOn()
{
Health -= 2
//yield for 3 seconds
}
You can start a coroutine from Update but in your case it looks like you should either do that in Start or start a coroutine there - here’s the Start version:
function Start() {
while(true) {
if(On) {
Health -= 2;
yield new WaitForSeconds(3);
}
yield null;
}
}