Adding an array of variables into actors in the world

Hi there, I’m making a save and load system where the game saves variables of a parent actor and adds the variables of its children into an array that is then saved. Once it is saved it then loads and puts the variables back where I want them, I am using structs and a struct array.

I am able to get the game to save and load fine but with one major issue, that being the variables aren’t loading into the correct actors. What I have at the moment is…

This gets the actors in the world which currently is 2 actors. So for each loop it gets the array that I had saved and sets the information residing at that index into that actors struct variable.

This isn’t precise and the code doesn’t know which struct info to add to which actor. Does anyone know how I can tell it which actor to give which struct variable? Sorry if this is confusing let me know if you need any more info. Thanks!

Thanks to unit23 I got the idea to give each actor its own specific ID. I made an array of the parent class. Then using a for each loop node I could input all actors in the scene into that array at a specific index. That index would relate to a number I gave each child which I set as a new integer variable for each child created. So the code knows where each actor is in the array. Thanks for the help!

This blueprint shows how to set player IDs (in multiplayer, may offer some ideas), Proper architecture for updating a UI in a lobby system - C++ Programming - Unreal Engine Forums

Before the loop i would set the actor class array up, then make a break (when right clicking the exit node of the class array variable) from that, which includes all class actor variables. Then work from there, with your loop.

Basically each actor needs a unique ID, which could be related to a unique actor tag.

For each loop get ID (via break), branch then from that ID, and add the code required for each ID. If you have more than 10 it will become kind of messy with many nodes, but currently have no other idea. Maybe make actor groups which share the same setup, those class actors can be setup via your game mode default settings too, (when you set this code up inside your custom gamemode blueprint, and add classes). So if you have like 5 actor class arrays, those could have each their own child customizations, explained in this video around the 3 min mark https://docs.unrealengine.com/latest/INT/Videos/PLZlv_N0_O1gbY4FN8pZuEPVC9PzQThNn1/OVrfHO2DdOs/index.html