Display Time in UI to Help with Animator


It’s quite challenging getting enemies to swoop by if you don’t know what time you need things to happen, so I made a little timer text script to display the time in minutes and seconds to the UI.
There might be a better way to do it, however, I hope it will help in the meantime!

(I made a separate text gameObject and attached this script)

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class DisplayTime : MonoBehaviour
    Text timeText;
    float timer;
    string min;
    string sec;

    void Start()
        timeText = GetComponent<Text>();

    void Update()
        timer += Time.deltaTime;
        min = Mathf.Floor(timer / 60).ToString("00");
        sec = Mathf.Floor(timer % 60).ToString("00");
        timeText.text = min + ":" + sec;
1 Like

Privacy & Terms