![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | Artium Nihamkin |
When a certain condition in the game is met, I want to pause the game for few seconds and then restart.
In a node where this condition is checked (called ReleaseArea), I call $Timer.start()
and tight after that get_tree().set_pause(true)
.
Timer’s timeout
signal is connected to this node, and in that callback I call get_tree().set_pause(false)
and get_tree().reload_current_scene()
.
I also set the timer not to pause.
In the debugger I can see that the function is called, also the scene is reloaded, but the tree is not resumed, like get_tree().set_pause(false)
had no effect.
I also tried the 3.0 way - get_tree().paused = false/true
.
signal time_changed
export var seconds_left = 5.0
func _ready():
set_process(true)
func _process(delta):
seconds_left = max(0.0, seconds_left - delta)
emit_signal("time_changed", seconds_left)
if (seconds_left == 0):
$Timer.start()
get_tree().set_pause(true)
func _on_Timer_timeout():
get_tree().set_pause(false)
get_tree().reload_current_scene()