||Topic was automatically imported from the old Question2Answer platform.
This is maybe endemic to game development, but I seem to find a dozen articles about how to do everything but what I am trying to do with timers.
Right now my goal is just to get the timer to countdown and the text label to show that happening. I have a gamemager with the timer object and label that now holds a static value of x seconds.
In game manager script I have created the variable so:
onready var Timer : Label = get_node(“TurnTimer/TurnTimerLabel”)
And that currently static label is in the sidebar UI. I need eventually to have that reset at every end turn when it hits 0 or if the End Turn button is pressed.
But no tutorials I have looked at address this. If I can get this answer it may fill in some blanks about how this all fits together and I could move ahead.
script label so it gets
time_left from timer and displays it in
process, whenever timer is not
timeout signal to the label, and lead it to resetting function on signal receival
connect end_turn button to the same method, so they both have the same effect, making timer
paused = true or change its display in label
I appreciate the response it just leave me with more questions.
1 you mean the label gets its own script?
2 What is “process” in this context?
3 does the resetting function go in game manager script?
I have examples for updating labels at end of turn but no examples for continually running one.
If you know any articles I could read about how all of this type of thing connects I would be glad to read it, it seems it should not be this difficult or confusing.
floatingdev | 2022-09-29 01:32
1 and 2. It doesn’t matter where it is scripted. The important thing is, that this part of code should be located in
process()function. It will be easier to read if it is in solitary script.
3 To reset timer You just make it
start() again. It will start counting from
You can also pause it and restart it from paused time with
paused = true and
paused = false
Continual update must always be performed in some
process()function. Just get a reference to your timer node, and get its
time_left. With this info You can then
$Label.text = str(timer.time_left)
If You haven’t heard about signals yet, now is the good time to do this :). I recommend Godots documentation, just search for signals.