I'm working on a Tower Defense game. There is a save button that saves the player's current world and the towers they have built. The information on the towers is recorded as 3D Array. That is 0: Type, 1: Level, 2: Position
And the code of the load button is like this:
get_tree().change_scene("res://Scenes/" + data["current_world"] + ".tscn") #Changes scene to saved world.
var world = get_node("/root/World") #Gets new scene root.
for i in data["towers"]:
var t = load("res://Resources/Towers/" + i + ".tscn").instance()
t.level = i
t.global_position = i
The scene is reloaded in the last saved world, but the towers are invisible and unresponsive in the scene even though they appear in the SceneTree and give output in their _ready() functions.
Another interesting thing is that if I don't change the scene, the towers can be reloaded at the saved location with no issues. How can I solve this problem?