Reload scene

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Pedro Karut Gimenez
:warning: Old Version Published before Godot 3 was released.

Hi Guys! I have a question and I believe it can be from another guys too. So, here it is: I have a main scene in wich I instance a lot of scenes that are collectable itens and all theses “children scenes” are son of a node called “generated”. When this phase ends, I want it to restart but I can’t find a way to kill all the nodes that are child of “generated” and later add the “generated” node to readd its children. I am really stuck in this problem. Thanks!

I forgot to mention that this main scene has an autoload script :slight_smile:

Pedro Karut Gimenez | 2016-08-03 22:46

What do you mean by “readd the children”? Why did you deleted the nodes in the first place?

Zylann | 2016-08-03 23:54

I am not sure if i get exactly what you want… sooo, “generated” is child of (lets say) “main”, its generated thru script (lets say, random position etc) and you want to reload “main”? Why? To regenerate “generated”? :slight_smile: Why not rerun your my_fill_generated_func()? :slight_smile: Or for n in get_node("generated").get_childs(): n.set_hidden(false) or… … …

Or something like “self.get_parent().add_child(load("res://my-main-node.scn").instance()); self.queue_free()”? :slight_smile: (i dont think this is good idea, but hey, we dont know what you want and what you have :slight_smile: )

splite | 2016-08-04 13:05

I got your point splite, that’s cause my autoload script is letting me crazy hahahaha. I am going to try, but what I really want is to change the scene and when it comes back, I wanted the script to rerun so that the children are regenerated.

Pedro Karut Gimenez | 2016-08-04 14:53

Btw, tutorial on changing scenes in godot.

And what “has autoload script” means? AutoLoads (Project Settings → Autoload) are singleton for entire game, not scene nor node, you cant “reload” them. Sorry, but i have feeling this is issue about node hierarchy & management, not reloading :slight_smile: We can help you to resolve that, but we need more info :slight_smile:

splite | 2016-08-05 07:32