Hello, I’m trying to make a clock that counts time normaly in unity and the seconds are beeing wierd. But because this is a game i want the time to run faster, so I added a * 8 after Time.deltaTime. Maybe that is messing it up ? I realy don’t know.
anyway this is the code.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class TimeCycle : MonoBehaviour {
[Header("Time")]
[ShowOnlyAttribute]
public float time;
[Space(7)]
[Header("Time of day")]
public float morningTime;
public float dayTime;
public float nightTime;
[Space(7)]
[Header("Time Bool")]
public bool isMorning;
public bool isDay;
public bool isNight;
[Space(7)]
[Header("Clock UI")]
public Text clockText;
private float minutes;
private float seconds;
void Start(){
isNight = true;
}
void Update(){
time += Time.deltaTime;
if (time > morningTime && time > morningTime + 0.001f ){
isMorning = true;
isDay = false;
isNight = false;
}if (time > dayTime && time > dayTime + 0.001f){
isDay = true;
isNight = false;
isMorning = false;
}if (time > nightTime && time > nightTime + 0.001f){
isNight = true;
isDay = false;
isMorning = false;
}
if (time > nightTime + 0.001f) {
time = 0;
}
minutes = time / 60;
seconds = time % 60;
clockText.text = minutes.ToString("F0") + (":") + seconds.ToString("F0");
}
}
The seconds count up to 30 then the minutes change to 1, the seconds contuniue to 60 the got back to 0 and finaly when they reach 30 again the minutes change to 2.
Thankyou for helping.