This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes

Hi, I making a racing game project and i have a problem with get_tree().paused....
I am using it first time for the "lights", when the race is started. After the lights out, get_tree().paused = false then i can pressed escape button for "pause menu" in the race. But it is not pause game (its just instance pause menu - witch have in script if is _ready(): get_tree().paused = true, but it is not hapend).
But when i delete lights from the files the "paused menu" works, but there is nothing betwen them, just same parent call "main".
Scene tree after instancing: main/racing gui/lights and main/paused menu/...
Both of them have Paused mod change to proces, other nodes in the tree have Inherit. Does somebody know where is a problem? Can it be a bug of godot?

in Engine by (61 points)
edited by

Are you sure your pause menu is pausing the scene tree AFTER the lights unpause it?

yes, I am sure, because player can not move until the lights are out…
here is the part of lights script (light is var, if Lightstimertimeout, light +=1 and game_run is var in main scene after that start working escape button for pause menu):

func _process(delta):
if light >= 6:
    get_tree().paused = false
    get_parent().get_parent().game_run = true
    if transparency != 0:
        transparency -= 0.02
$CanvasLayer/Light_Sprite.modulate = Color(1,1,1,transparency)

1 Answer

0 votes

I do not know why, but this works (i change script in pause menu):

extends Control

var pause = false

func _ready():
    pause = true

func _process(delta):
    if pause == true:
        get_tree().paused = true
        get_tree().paused = false

func _on_RESUME_pressed():
    pause = false

func _on_QUIT_pressed():
by (61 points)

you could use a setget function to handle the pausing

var paused: = false setget set_paused
var scene_tree = get_tree()

func _unhandled_input(_event):
    if Input.is_action_just_pressed("pause"):
        self.paused = not paused

func set_paused(value: bool):
    paused = value
    scene_tree.paused = value
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 Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.