0 votes

I'm creating a boss fight in my game and I've set the scene to reload whenever my character dies. I want to timer to keep going even if I do reload _ current _ scene().

How can I do that?

in Engine by (28 points)

2 Answers

0 votes

If the timer is in the scene it will always reset it self if the scene is reloaded.
Instead you could save the time that allready passed into a singelton before you reload. This variable than doesnt reset with the scene. After the scene is reloaded you can get the value back and set the timer accordingly.

by (29 points)
+1 vote

You don't need to reload entire scene. You can reload just one node (and its children). This is the best thing about Godot. Each scene is like a node. So you can create a Scene (say Main.tscn) and have a top level Node (say Main). Attach the timer to your Main node. And the rest of the game scene can be child of the Main node, let's call it 'Game'. So whenever the character dies, you just reload the 'Game' node. And the timer being part of parent node (Main), will continue to tick.

In order to reload a node, I guess you have to call removechild, and then addchild on the parent node.

by (28 points)

Just queue_free() the Game scene. No need to remove_child().

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.