UnityScripterAI
Discord ↗
Link Copied to Clipboard
×
"create a timer for my game"
using System.Collections; using System.Collections.Generic; using UnityEngine; public class Timer : MonoBehaviour { public float timeRemaining = 60; public bool timerIsRunning = false; private void Start() { timerIsRunning = true; } void Update() { if (timerIsRunning) { if (timeRemaining > 0) { timeRemaining -= Time.deltaTime; } else { Debug.Log("Time has run out!"); timeRemaining = 0; timerIsRunning = false; } } } }