You're the only one who explains that you have to make a TextManager and attach the script to it so that it lets you drag the Text later on, thank you so much, you saved a brother's day.
Currently 4am, 12 hours before deadline, and this has reimbursed my mental health to a neautral state and I now can take over the whole. Great tutorial.
BMo, I've recently started following you and your amazing! Very clear and well spoken explanations. Please don't stop doing what you do, it's so great!
The tutorial is very good and it works correctly, can you do a tutorial on how to make a timer but with minutes and seconds? I would really appreciate it :D!
great video but the audio is so low :( i love it but please try to make it louder next time (i put as loud as i could in all my settings and it was still way too quiet to listen)
I'm not 100% sure but there's a small issue with the code currentTime = countDown ? currentTime -= Time.deltaTime : currentTime += Time.deltaTime; This is because you wrote this currentTime = currentTime -= Time.deltaTime or currentTime = currentTime += Time.deltaTime i think what you meant to do is currentTime = countDown ? currentTime - Time.deltaTime : currentTime + Time.deltaTime;
Excellent! I love this! BTW, can this same code be used to... say, keep track of total playtime? Like, say I played a game for 7 hours, 21 minutes, and 45 seconds and I want to display that in the credits... is that possible with this code, or similar code... or will I need something completely different?
You could probably use the script pretty much as-is, start the stopwatch as your game starts, and then at the end of your game do a conversion for the value of currentTime from seconds to HH : MM : SS
por favor , un cronometro en retroceso que marque segundos, minutos y dias y que tras salir del juego se detenga , al igual que cuando se pause. gracias
I have a working version of the script (chatgpt fixed it for me lol) using System.Collections; using System.Collections.Generic; using UnityEngine; using TMPro; public class Timer : MonoBehaviour { [Header("Component")] public TextMeshProUGUI timerText; [Header("Timer Settings")] public float currentTime; public bool countDown; [Header("Limit Settings")] public bool hasLimit; public float timerLimit; void Update() { // Updated the currentTime calculation currentTime = countDown ? currentTime - Time.deltaTime : currentTime + Time.deltaTime; // Fixed the condition checks for hasLimit if (hasLimit && ((countDown && currentTime = timerLimit))) { currentTime = timerLimit; SetTimerText(); timerText.color = Color.red; enabled = false; } SetTimerText(); } private void SetTimerText() { // Format currentTime to 2 decimal places timerText.text = currentTime.ToString("F2"); } } (the F2 is the decimal places i think, so if you change it to like F3 it changes the decimal place)
I have a fix. I think if you change the F2 in the timertext.text at the bottom it changes the decimal places. but this one is on 2 using System.Collections; using System.Collections.Generic; using UnityEngine; using TMPro; public class Timer : MonoBehaviour { [Header("Component")] public TextMeshProUGUI timerText; [Header("Timer Settings")] public float currentTime; public bool countDown; [Header("Limit Settings")] public bool hasLimit; public float timerLimit; void Update() { // Updated the currentTime calculation currentTime = countDown ? currentTime - Time.deltaTime : currentTime + Time.deltaTime; // Fixed the condition checks for hasLimit if (hasLimit && ((countDown && currentTime = timerLimit))) { currentTime = timerLimit; SetTimerText(); timerText.color = Color.red; enabled = false; } SetTimerText(); } private void SetTimerText() { // Format currentTime to 2 decimal places timerText.text = currentTime.ToString("F2"); } }
You're the only one who explains that you have to make a TextManager and attach the script to it so that it lets you drag the Text later on, thank you so much, you saved a brother's day.
dude i never understood how to do that type of if else statement until now! you're the first person i've seen explain that clearly. awesome vid!
Tick tock, Time to binge watch BMO tutorials. Another good one 👍
Currently 4am, 12 hours before deadline, and this has reimbursed my mental health to a neautral state and I now can take over the whole. Great tutorial.
This is fantastic. Going to send this to my team to watch. Keep this content coming!
Finally! All the other tutorials were either too long or were outdated. This helped so much ty.
Hey BMO, good to see you upload.
Always learn something.
BMo, I've recently started following you and your amazing! Very clear and well spoken explanations. Please don't stop doing what you do, it's so great!
Another great tutorial from the legend BMo
🙏
The tutorial is very good and it works correctly, can you do a tutorial on how to make a timer but with minutes and seconds? I would really appreciate it :D!
Cool tutorial 🔥❤
Appreciate it
Top notch video here.
Tysm
This is a lovely tutorial, thank you!
How do you make it so that it counts minutes as well please?
Thank you so much!
Really cool stuff
Thanks, really helpful! :D
everything works however the timer does not appear on the screen it only appears once the timer countdowns the number that i put.
how do you make it so that it counts minutes as well? it goes over 60 seconds and idk what the article listed can help with that
Hey, nice video and usefull since its specific to text mesh pro.
great video but the audio is so low :( i love it but please try to make it louder next time (i put as loud as i could in all my settings and it was still way too quiet to listen)
unity won't let me change the format in the way that you did, it says that I can't convert int to string
help
How can I stop timer with OnTriggerEnter (Touching to an object etc. )
How would yo go about pasuing the timer whenever you want as a fuction? I want the time to be displayed at the end of a level
Thank you!!
How is it possible to change into something that converts to minutes?
I'm not 100% sure but there's a small issue with the code
currentTime = countDown ? currentTime -= Time.deltaTime : currentTime += Time.deltaTime;
This is because you wrote this
currentTime = currentTime -= Time.deltaTime or currentTime = currentTime += Time.deltaTime
i think what you meant to do is
currentTime = countDown ? currentTime - Time.deltaTime : currentTime + Time.deltaTime;
yeah he is assigning two times unnecessarily.
this fixed the issue I was having thank you!
I got like 400 errors can you please help
its TIME to subscribe ~~ 😂😂😂😂
Please do it.
When I test this out in unity it works perfect, but when I build it as a WEBGL the timer isn't there. Any ideas?
Excellent! I love this! BTW, can this same code be used to... say, keep track of total playtime? Like, say I played a game for 7 hours, 21 minutes, and 45 seconds and I want to display that in the credits... is that possible with this code, or similar code... or will I need something completely different?
You could probably use the script pretty much as-is, start the stopwatch as your game starts, and then at the end of your game do a conversion for the value of currentTime from seconds to HH : MM : SS
How to slow down this timer ...?
por favor , un cronometro en retroceso que marque segundos, minutos y dias y que tras salir del juego se detenga , al igual que cuando se pause. gracias
My Visual Studio is totally playing with me as it doesnt understand "||" and i cant make limit then.
🔥🔥🔥🔥
would anyone happen to know off the top of their head how to format the timer so it goes "Minutes : Seconds"
how to record the time and display it.
mine doesnt work for some reason, idk if its because of brackets, the timertext component is not showing up in unity.
If you share your script I can see if theres any issues
how do i set it in minutes so every time it gets to 60 it starts showing minutes passed?
thnx chichaaa
Decimals: 7:51
Why does this not work for me :(
Thxx
Can you paste the script in the description or in the comment section? I have having alot of difficuties
I have a working version of the script (chatgpt fixed it for me lol)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
public class Timer : MonoBehaviour
{
[Header("Component")]
public TextMeshProUGUI timerText;
[Header("Timer Settings")]
public float currentTime;
public bool countDown;
[Header("Limit Settings")]
public bool hasLimit;
public float timerLimit;
void Update()
{
// Updated the currentTime calculation
currentTime = countDown ? currentTime - Time.deltaTime : currentTime + Time.deltaTime;
// Fixed the condition checks for hasLimit
if (hasLimit && ((countDown && currentTime = timerLimit)))
{
currentTime = timerLimit;
SetTimerText();
timerText.color = Color.red;
enabled = false;
}
SetTimerText();
}
private void SetTimerText()
{
// Format currentTime to 2 decimal places
timerText.text = currentTime.ToString("F2");
}
}
(the F2 is the decimal places i think, so if you change it to like F3 it changes the decimal place)
i dont understand my unity dont like the 11 line??? 3:40
nvm i fixed it
Unity literally yells at me that I can't convert int to string
same here, did you fix it?
I have a fix. I think if you change the F2 in the timertext.text at the bottom it changes the decimal places. but this one is on 2
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
public class Timer : MonoBehaviour
{
[Header("Component")]
public TextMeshProUGUI timerText;
[Header("Timer Settings")]
public float currentTime;
public bool countDown;
[Header("Limit Settings")]
public bool hasLimit;
public float timerLimit;
void Update()
{
// Updated the currentTime calculation
currentTime = countDown ? currentTime - Time.deltaTime : currentTime + Time.deltaTime;
// Fixed the condition checks for hasLimit
if (hasLimit && ((countDown && currentTime = timerLimit)))
{
currentTime = timerLimit;
SetTimerText();
timerText.color = Color.red;
enabled = false;
}
SetTimerText();
}
private void SetTimerText()
{
// Format currentTime to 2 decimal places
timerText.text = currentTime.ToString("F2");
}
}
good, but better with source code
do you still need the code? I have it working
chatgpt helped lol
ᵖʳᵒᵐᵒˢᵐ
you're the best