Save/Load position of all instances

I have tried following the tutorial on save/ load but I it is not giving the result I am hoping.

I have an object group called “Draggable”.
In this group I have for the moment three objects.
In my scene I have multiple instances of these objects.
I have a save button that should save the X,Y of each instance.
The next time I preview the game the position of the objects should be set from the save.
-the issue is that all the instances start at the same x,y position instead of there individual ones.

Oh I am missing an instance variable ID

Instead of an ID, save the object name. When you load the location, you recreate the object from it’s name, and then assign it an ID if that’s necessary.

It means you won’t have to worry about allocating an unique ID or creating an instance variable for each object that becomes a member of the Draggable group.

Thanks for the idea.
I will try using your method tomorrow to see the difference. But I can imagine that what I am doing could give an issue when loading the game as the object instance might not know witch instance gets witch ID…

Just to wrap up my method…
I have manually set an ID variable for each instance (1,2,3…)
Instead I would like to loop through and give all an ID.
Could I do it like this?

Why? Unless you use the IDs to link or connect 2 Draggable objects, there’s no need for them to be saved.

What I’m saying is to save the position and the object name (you can use Draggable.ObjectName() for that). When you load the details, just allocate each object a new ID as it is created.


This looks inefficient. You can merge the two Repeat blocks at least.

And as the events stand, all they will do is change the object’s ID every time you save. What’s the point of that? If you have an ID, it should be allocated upon object instantiation.

Thank you for the feedback. You are a more experienced developer than I, so I know that you are pointing out something I need to deal with. I have read your comments several times and do see that saving the IDs might not solve anything. But there is a gab between me seeing it and me understanding it… I might have to work on some other problems before I return to the saving things and hopefully I have a better understanding. Is it because you think that the ID is completely redundant?

A thing I am struggling with understanding is that at the moment I have premade the layout of different objects in the editor. My head dos not understand how there is a coupling between the right object at the right position and with the right value of the status-variable (not all objects have a status-variable).
I will probably end up giving the player total controle of creating new objects and deleting old ones. From what I understand from your posts I should give the new object instance an ID on creation.

Only if you never reference the ID in any of the events (other than saving and loading). If you don’t use it, why bother saving it? And if you do use it, is it to identify it when dragging (no need to save), or to create a connection between this object and another (in which case do save it)?


What I do with the objects is clear them all out of the scene before I load the saved position details. These details include the object name, so then I can create the object from the group. I only store IDs if 2 object need to be connected/linked (I use the Sticker extension).


Yes, but (again) not if the IDs are used to link 2 objects.