Hello guys! Im trying to adjust filler based on time like this
https://docs.unity3d.com/ScriptReference/UI.Image-fillAmount.html
void Update ()
{
//Reduce fill amount over 30 seconds
cooldown.fillAmount -= 1.0f/30* Time.deltaTime;
}
Its very simple, in update it works perfectly, but i need to call this in a coroutine like this:
void Update() {
Debug.Log("update");
if (!phaseControlIsRunning)
StartCoroutine (BattlePhaseControl());
}
IEnumerator BattlePhaseControl()
{
phaseControlIsRunning= true;
monsterInfo.PrepareTime/ * Time.deltaTime;
yield return new WaitForSeconds(0);
phaseControlIsRunning = false;
Debug.Log("coroutine");
}
Now i need to divide PrepareTime by 2, because coroutine is called twice time less than update like this.
If i dont do this, 5 seconds will be like 10, 20 like 40 etc. I know its easy to divide by 2, but can anyone explain why is that?
This is my log: [86273-без-имени-1.png|86273]