What’s up! I’m stuck with an idea that I can’t program.
I have a variable that increases from 1 by 1, that is, each time an action is performed, 1 is added to it. But if the Player receives a hit, he loses everything and returns to zero … Every time he adds 1, a coroutine is executed. And every time it is reset to 0, another one has to do so. This would not be a problem if it were not because as I check the status of my variables in Update the actions (placed in coroutines) are repeated continuously as long as the value remains and yet I want the actions to only be executed ONCE but EVERY TIME that happens.
I know probably there´s a stupid solution but sincerely I really appreciate any help.
I tryied with a bool condition in coroutines that “switchof” themselves when finishing but it didn´t work
IEnumerator Action ()
{
if condition
{
//do something
condition = false;
yield return null;
}
}
That works once but not as desired.