Question by
Ogdy · Oct 07, 2015 at 09:38 PM ·
javascriptcoroutineloopwhile
How to change a variable used in a loop for the outside ?
Hello,
I've made a coroutine which applies a buff to a player.
It works like this :
Applying Buff :
stoptime=Time.time+buffDuration;
StartCoroutine("BuffAttack");
Coroutine :
function BuffAttack();
attack=2;
while (Time.time<stoptime){
yield WaitForSeconds(0.1f);
}
attack=1;
I want to be able to extend the duration of the buff while it is applied. I use for this the following :
Refreshing Buff :
stoptime=Time.time+duration;
However, the stoptime in the while function is always the same. How can I deal with this ? Thanks a lot.
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612040431im_/https://answers.unity.com/themes/thub/images/avi.jpg)