Right now I’m trying to get the seconds from a timer and then format it into minutes and seconds. So I though doing this:
timer += Time.deltaTime;
int min = timer/60;
int sec = timer%60;
But I don’t know how to do it in unity.
Right now I’m trying to get the seconds from a timer and then format it into minutes and seconds. So I though doing this:
timer += Time.deltaTime;
int min = timer/60;
int sec = timer%60;
But I don’t know how to do it in unity.
I’m doing this but I don’t know why the timer isn’t acceptable on the math operations there.
timer += Time.deltaTime;
Mathf.FloorToInt(timer);
int min = timer / 60;
int sec = timer % 60;
text.text = min + ":" + sec;
and now I have changed the code and It’s working but I don’t really know why it wasn’t working before.
timer += Time.deltaTime;
int min = (int)timer / 60;
int sec = (int)timer % 60;
text.text = min + ":" + sec;