0 votes

I'm building a platformer where when the player dies, a new one respawns, leaving the old player where it died. After a certain number deaths, the player is kicked out to the main menu and must restart the level. This worked fine, until I quickly clicked the button to reload the level after dying, and all the old players were there.

When the player loses, this function is called:

get_tree().reload_current_scene() # My attempt to get all the nodes to reset. Makes no noticeable difference
get_tree().change_scene("res://Scenes/MainMenu.tscn") # After saving, load the main menu scene

When the button to load the level is pressed, this function is called:

get_tree().change_scene("res://Scenes/Level2.tscn")

If I wait a few seconds before hitting the level load button, all the instantiated nodes are removed, and the scene goes back to its default state, as expected. It's only when I quickly reload the level that the instantiated nodes are preserved.

Is this something I'm doing wrong with loading/unloading scenes, or is this a bug in the engine?

asked May 2 in Engine by cvieira (19 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 How to use this Q&A? before posting your first questions.