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.

godotengine.org | Twitter

0 votes

I solved the following problem I was instancing the shooter as a child of root not as a child of the current scene. Changed it and it now works,


I load a scene and it spawns a wave of marbles. Shooter tower is placed and shoots marbles.

It I reload the scene and I have tried several different ways the shooter tower is still shooting marbles even though he is not visible. You can see the marbles popping as they are shot- but the shooter tower is not present.

I tried to make a screen recording but it only recorded first scene not the current scene.

I assumed changescene, reloadcurrent_scene etc freed all nodes and left memory. But they are still running in background.

Could someone explain to me how to change or reload a scene and kill the previous scene so no unwanted instances are running?

here are methods I have tried:

#attempt 1
    func _on_restartButton_pressed():
        print('restarted scene')
        var scene = load("res://desertMap01.tscn")
        var new_scene= scene.instance()
        get_node("/root").add_child(new_scene)
        queue_free()

 #attempt 2   
    func _on_restartButton_pressed():
        print('restarted scene')
        get_tree().reload_current_scene()

  #attempt 3
    func _on_restartButton_pressed():
        print('restarted scene')
       var error_code = get_tree().change_scene("res://desertMap01.tscn")
        if error_code != 0: 
            print("ERROR: ", error_code)

Thanks JB

Godot version 3.23
in Engine by (18 points)

Please log in or register to answer this question.

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.