Instanced Object Names

Hey there,
I have a question concerning instanced objects.
I have testet agoose77’s saveloader script and it works great except for instanced objects.
I wanted to know why it doesn’t work well for instanced objects and figured out, that instanced objects have the exact same name in the runtime.
Why is this? I thought each object has a unique name while bge is running?
How can I have access to a specific instanced object? Is this even possible?

Does someone have some experience in this direction?

I hope you can share some thoughts to this topic :slight_smile:


Instances and added objects share the name of the “master”.

It is not a big deal with saving. You just save them as before. For each object name save a list of object data rather than than the the data of the single object.

It is a bit more complicated on loading.
First you need to remove all objects that can be an instance or an addObject.
Then you have to add as many copies as you have stored data from.
Objects with the same name should be from the exact same type!
You apply the restored object data to the newly added objects. It does not matter which one gets the data of what original. The basic object should be the same.

Be careful when adding parents. They add their children too. That can result in two objects (the first added via the parent, the second added via the object itself).

See the SaveLoader for an example.

I might update it to support instancing

Thanks monster! This makes it clearer for me!

yeah great… I think this would be a usefull addition!

I am creating my own save script now… A great exercise :slight_smile:
I will also try to implement the loading of instanced objects!

It is simple enough to check if an object has a parent in the python save script. I can’t think of the code off the top of my head, but I know that I did it.