I take it the counter that displays the remaining time is a scene, and that both over- and under world use an instance of that counter scene? And that 400 is some sort of default value?
When you enter the pipe from the overworld into the underworld, you’re likely switching scenes. The former is unloaded, and the latter is loaded. You need to add code that can store the remaining time, and you need to edit the counter so that it can retrieve that stored time when the counter object enters the scene tree.
Make a new scene and set a Node
as its root node. Rename the root node CountdownManager
. Add this script to CountdownManager
:
extends Node
@extends var countdown_value : int = 0
If you make that script an autoload, you can access it from any other scene. For instance, you can access it from the warp pipe scene. When the player goes down the warp pipe, simply get your current countdown value and store it in the autoload.
In your counter scene, simply get the data from the autoload on ready:
# counter.gd
func _ready()->void:
value = CountdownManager.countdown_value