I’m making a timer for my game and I’m trying to make it similar to actual seconds and minutes. I was using Time.deltaTime but whenever I put a large number like 100 it decrease very fast and stops it around normal seconds when it reaches around 5 or 6. My code is
public TextMeshProUGUI displayMinutes;
public TextMeshProUGUI displaySec;
private string input;
public float result;
public float subTime = 1f;
public void ReadScriptInput(string Time)
{
input = Time;
Debug.Log(input);
result = float.Parse(input);
}
void Start()
{
}
void Update()
{
SubtractTime();
DisplayTimer(result);
}
public void SubtractTime()
{
for (float i = 0; i < result; i++) {
result = result - Time.deltaTime;
Debug.Log(result);
}
}
public void DisplayTimer(float currentTime)
{
currentTime += 1;
float minutes = Mathf.FloorToInt(currentTime / 60);
float seconds = Mathf.FloorToInt(currentTime % 60);
displayMinutes.text = Mathf.Round(minutes).ToString();
displaySec.text = Mathf.Round(seconds).ToString();
}
is there any solution to this issue?