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