display mins as second in a timer.

How can I when my counter is 60 that he keeps using seconds to display mins. So 60, 61, 62, 63, 64 etc.

using UnityEngine;
using UnityEngine.UI;

public class Timer : MonoBehaviour
{
    public Text timerText;
    float timer = 0.0f;

    // Start is called before the first frame update
    void Start()
    {
        timer = Time.time;
    }

    // Update is called once per frame
    void Update()
    {
        timer += Time.deltaTime;
        float seconds = timer % 60;

        timerText.text = seconds.ToString("f0");
    }
}

Just remove the % 60 … (It’s often referred to as modulo operator, even though it just calculates the remainder).

2 Likes