I have been working on a Sanity level of a player and I’ve been using Coroutines to drain 5 sanity every second and that Coroutine I am using is just ignoring WaitForSeconds. I need help.
function SanityDraining(){
if(lanternLight.enabled == false){
StartCoroutine(sanityDrain(1.0));
}else{
StopCoroutine(sanityDrain(1.0));
}
}
function sanityDrain(waitTime : float){
playerSanity = playerSanity - sanityLoss;
yield WaitForSeconds(waitTime);
}
I have called the Sanity Draining function in Update function and its working, everything is working but its just ignoring yield. I have a script that I’ve done with players light, also using coroutines and it works perfectly. I dont know what seems to be the problem here.