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?

asked Jul 14, 2019 in Engine by Nanogines (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.

answered Jul 14, 2019 by INeeedHealing (25 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.

answered Jul 14, 2019 by vgarg (27 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 How to use this Q&A? before posting your first questions.