The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates. | Twitter

0 votes


I need a global scene in my 2D game, therefore I made this to global in AutoLoad tab. But in this case this scene always visible, therefore I set its visibility to false in its _ready() function.
But how can I switch it back when I want to see again this scene?
I try this from the Start button of the title scene:

extends Button

onready var palya=preload("res://palya1.tscn")

func _process(delta):
    if Input.is_mouse_button_pressed(BUTTON_LEFT):
        var p=palya.instance()

but nothing happen. I use Godot engine 3.3. Somebody can help me?

Godot version 3.3
in Engine by (52 points)

1 Answer

0 votes

You are creating a new scene instead of using your global scene. You can access your global scenes or scripts with their name. If your autoloaded scene name is palya1 then doing palya1.visible = true should be enough.

by (600 points)

Hello Enfyna and thanks for your answer, but in this case I get a packed scene error message.
But I think, I forgot write "gettree().getroot()" before "add_child()"...

How did you write your code ? What is your global scene name ? If your global scene name is palya then this should work :

extends Button

func _process(delta):
    if Input.is_mouse_button_pressed(BUTTON_LEFT):

You dont add_child a global scene because it is already added.

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.