$begingroup$

I’m making a easy recreation interface. When fillAmount > 0, the timer is stopped and reset. I need to restart the timer if the fill quantity doesn’t change for 3 seconds. All the code does now’s counting 3 seconds after which displaying the time when it stops. How do I repair it?

non-public float beginTime;
non-public float reStartTime;
public Barscript barscripts;

void Start() {
    beginTime = Time.time
    DefaultImg = GetComponent<Image>();
}

void Update() {
    float t = Time.time - beginTime;
    reStartTime = 3;
    float t1 = reStartTime - beginTime;

    string hours = ((int) t / 6).ToString();
    string minutes = ((t % 6) * 10).ToString();

    Debug.Log(barscripts.fillAmount);
    
    if (batscripts.fillAmount > 0) {
        DefaultImg.sprite = Emoji3;
        beginTime += Time.deltatime;
        timerText.textual content = " 0   :   00 "
        Debug.Log(t1);

        if (t1 < 0) {
            timerText.textual content = hours + "   :   " + minutes;
        }
    }
}

Here’s a pattern picture of what I’m getting in the meanwhile.

$endgroup$

0

You should log in to reply this query.

Not the reply you are searching for? Browse different questions tagged .