0 votes

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():

func _process(delta):
    seconds_left = max(0.0, seconds_left - delta)
    emit_signal("time_changed", seconds_left)
    if (seconds_left == 0):

func _on_Timer_timeout():
asked Jun 10 in Engine by Artium Nihamkin (241 points)

1 Answer

0 votes

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: http://docs.godotengine.org/en/3.0/tutorials/misc/pausing_games.html

answered Jun 11 by SingingApple (368 points)

In my example, I whitelisted the Timer node.

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.