Download

Saving procedural item data in inventory

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, IDs alone will not work.

I have a sample inventory based on Objects here, but it is built on C++ :

UE Simple Inventory (github.com)




Does it save the objects? Can you even save objects?

The basic Unreal’s save game system does not support saving objects.

With the basic save system you have to create mirror variables in a USaveGame object and copy the variables of the object to save them manually.

Wouldnt that result in an absolute ton of saves?

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.

I realised i could just save as multiple arrays in 1 save object