I need to be able to save multiple random objects in an array. Optimally I could have some sort of generic “struct” variable, that saves whatever struct i want there, using struct name on a switch but that does not exist. I could make a bunch of individual arrays, storing structs, with the item itself pointing to an index on the array, but that would get extremely messy extremely quickly. Can anyone think of a solution? Besides having like 40 arrays on each character for every type of procedural item?
No, the default save system will force you to convert your objects to an array of structs when saving, then convert back from struct to object variables when loading.
That’s not too bad for performance, it’s just a gigantic waste of time because every time you develop new classes that need to be saved in a level, you will also have to create mirror structs for that class in the save game object… Over time you waste a lot of effort the more your game grows.
But the save system is perfectly fine if all you need to save are basic variables such as HP, Energy, single player stats, etc.
For complex stuff like an inventory, you have to put some work to save the objects.