The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates. | Twitter

0 votes

I want a timer to have a countdown that changes the scene when it reaches 0

in Engine by (20 points)

3 Answers

–1 vote

The question is? ;-)

I guess you a searching for a hint how to do it. Here it is:

There is a Timer node. Just use it. Put it in a scene that you load as a singleton. (See Project settings Autoload)

Just like you would do with background music that runs independent of scene changes.

If the question was "Do the all the programming for me, I don't want to read." then sorry, that this wasn't the answer.

by (3,370 points)

That was so sarcastically useful. signal aren't as trivial as an experimented user of godot might think. And using a singleton is even more complex for something as functionally simple as "change scene after a timer" (eg : a splash/title screen).

so i added an actual "i'll do your homework" (with code) answer, because this isn't a competition.

Sorry for being sarcastic at times. I just think that when people ask a favor of other people it might be justified to put some more effort in writing the question than just saying "I want".

I understand that englisch isn't the mother tongue of every writer (it isn't mine as well) and I understand that you sometimes need a pointer where to start.

Thank you for posting an answer with details & code. I also think (and forgot it beforehand) that this will be helpful for other people who are searching for an answer to that question.

Thank you for your understanding :)

Questions like this would certainly get a downvote if it was posted on StackOverflow.
Beginners need to learn how to spend some time and effort before asking a question.
I agree with your answer, as you have provided a high level solution to OP's question.

Aren't we glad this is not stackoverflow then ? :D
Considering the current state of godot, the simple fact that the OP is using it instead for unity is, imho, already a show of goodwill to learn.
If one wanted their homework done for them, they would unity because their homework has already been done and posted multiple time everywhere. That's what make unity the industry standard of indy game.

+1 vote

Doing this will be simple!

Get the timer node

Connect the on timed out signal

and under the timed out function (from the signal ) put your line of code that changes the scene

by (831 points)

That's what I did, but It doesn't do anything

and I dont even know If 1 stands out 1 second or 1 minutes, or 1 hour idk they just dont explain you a THING

I don't think 1 stand for 1 second as i put 0.01 as a timer and it still does nothing u heard meh

The 1 stands for 1 second. Also, did you call start() on your timer?

+1 vote

Since it have a good rank on google i'll answer it, the reference documentation doesn't have an exemple and it require to understand signaling.

extends Control

var timer = null

# Called when the node enters the scene tree for the first time.
func _ready():
    timer =
    timer.connect("timeout", self, "on_timeout")

func on_timeout():

in timer.connect() the first argument is the signal (the only signal Timer is emitting is "timeout". Self it the receiver of the signal, and ontimeout is a function name of your choice, i called it "ontimeout" but could have been anything.

And in this function call the change_scene code.

by (16 points)

This just gave me such an error

the way how to this is just use signal and just type "gettree().changescene("blabla whatever scene you made.tscn") underneath the automated made code inside that timer script I think there's just something wrong with what im doing i guess but this is the code im sure of it

oh actually I think 1 just stand as 1 second my bad

check both one shot and auto start in the right small corner when clicked Timer
and write the
"func onTimertimeout():
tree().change_scene("res://main menu.tscn")" on anywhere in current scene that you are looking at and write a script anywhere like yer playermodel or map idk and type that thing above it and set any time you want like 20 or 50 second when clicked Timer and
it just work i think

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.