How to save children in node?

Godot Version

4.6

Question

I need to figure out how you can have multiple instanced nodes and when instantiate a node in the instanced node it saves it and loads it on the start. so basically just saving the children of multiple of the same nodes but all of the children can be different.

Your description of the problem is not really clear.

3 Likes
const BOMB = preload("uid://c78fxbg212c4n")
const CANNON = preload("uid://d0cannonv1")
const LASER = preload("uid://m362pk144asa")

var item_list: Array[PackedScene] = [BOMB, CANNON, LASER]

Then iterate the list and load it. Or put them in a Dictionary and pick the ones that are loaded. Or store the UIDs in a dictionary and load those.

1 Like

sorry I’m horrible at explaining things. I’m trying to figure out how to save an object that has been instantiated in the scene but I have multiple nodes that are exactly the same and I want each of them to save differently so I can have multiple different objects being saved.

You want to change children node in instances of the same scene?

Maybe show the specific example of what you’re trying to do.

1 Like

From the limited information, I think that’s what you are trying to achieve:

-How to save/load multiple instance of the same scene, with different variables.

If that’s the case, your solution is not quite right. You should not need to save multiple scenes.

You probably need to create a custom resource that has the values of the ‘differentiated’ variables for each scene. Then you can just save the resources only, instead of the whole scene.

When you need to load them, you just instantiate the same instance of the scene and then load the custom resource for each scene.

so basically I have two buttons here and they are both the exact same buttons but one of them has an object instanced on it so the object is it’s child and I want to save the child for each button

Why not save the button with the child node inside and instantiate that multiple times?
This may be a complete misunderstanding. Apologies if so.

you’re good. it’s it just that each button can have different objects placed on them and some of them won’t have an object on it.

Then try to make the base scene for the button, and make a version with the child, and one without,
Or just make two variants without the first base button.
*nice project by the way

1 Like

thanks