Pause not resuming when called from timer callback

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: 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.

enter image description here

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()
:bust_in_silhouette: Reply From: SingingApple

The thing is after you do gettree().paused = true , the whole game will stop forever. After that is called, you cannot set paused back to false. You need to whitelist some nodes in order to get it back to normal state. Read this and you’ll understand: Pausing games — Godot Engine (3.0) documentation in English

In my example, I whitelisted the Timer node.

Artium Nihamkin | 2018-06-12 15:38