0 votes

Hello ! Thanks to ICatRegister, I now have a thread loading my ingame scene like that :

thread.start(self,"prep_scene", ResourceLoader.load_interactive("res://scenes/ingame.tscn"))

func _on_load_level_done():
    var level_res = thread.wait_to_finish()
    var scene = level_res.instance();
    goto_scene(scene);

func goto_scene(new_scene):
    current_scene.queue_free()
    current_scene = new_scene
    get_tree().get_root().call_deferred("add_child",current_scene)  

.
It all works perfectly fine. It launches the ingame scene, but then my restart button, set in the ingame scene's script, doesn't work anymore :

func on_restartbutton_pressed():
     get_tree().reload_current_scene()

I'd like it to reload the ingame scene but it looks like my ingame scene is not recognize as "current_scene".
do you know what I could replace this command with ?

thanks !

in Engine by (245 points)
edited by

1 Answer

0 votes
Best answer

You didn't set current_scene for SceneTree. Try adding this at the end of your goto_scene():

get_tree().call_deferred("set_current_scene", current_scene)
by (2,256 points)
selected by

case solved, thanks ! ;)

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.
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 webmaster@godotengine.org with your username.