How to make a time counter?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By ktotokarol

So I found this video. I don’t know if I should use Label or RichTextLabel as a “mother” node. With both options 0:0:0 is displaying but the counting doesn’t start. What should I do?

If you have any other solution it will also be awesome.

Also I would like the timer to stop when player collects for example 10 coins and display it.

:bust_in_silhouette: Reply From: exuin

It doesn’t matter if you use a Label or RichTextLabel as a parent node. They should act the same in this case. If the counting doesn’t start, did you connect the signal properly? And did you check “autostart” for the timer as well?

For the timer to stop when the player collects ten coins, you should have the node that manages the player’s inventory send out a signal to the timer that stops it. I’m not sure what you mean by “display it”, though. If you mean display the timer, as long as you don’t hide the text node it will be displayed. If you mean the number of coins, add another text node and update the number in it similarly to how the timer’s text is updated, only except when a coin is collected and not every millisecond.

Thanks for your answer!
I did everything as in a video I linked in a question. I did check the autostart and did connect the signal (like in the video). However, I don’t know if it isn’t working because it is quite an old video and something can work differently (?).

ktotokarol | 2021-01-16 13:48

I recreated the tutorial in the current stable version of godot and it still works. Perhaps you can show me your code?

exuin | 2021-01-16 20:52

I got to know why it doesn’t work. I didn’t notice that in the video ready() -> void: is changed to _process(delta):. I fixed that and now it works. Thanks for help :v

ktotokarol | 2021-01-18 20:19

I had a similar problem to create a time counter in the format days 0 hours:minutes:seconds 00:00:00, then I was able to solve it a bit more complex.

However, in a label under Node. I can make a video about it.

Since I am new I do not know if or where I can share the code.

If someone is interested you can contact me.