Save/Load with "object" type array not working?


I’m trying to implement saving and loading my inventory and equipped items. My entire inventory system is based upon a array of “object” type which contains the ItemTemplate items.

Now I’m trying to save and load this array of “object” type, the save seems to be working, but when I try to load it back in in my controller, the saved array i’m trying to load is empty and I have no clue why.

See screenshots for some of my save/load code.

the strange thing is, however, that i’m doing exactly the same thing with a array of “Texture2D” type and that is working perfectly.

Any clue why it is not working with an array of “object” type?

And if that’s not possible, how would you go about saving/loading inventory items?

Thanks in advance!

My guess is, object instances are invalidated when the game is closed? While textures are gotten straight from your content folder AFA I understand…

Now I tried saving the Item_Struct that’s on my ItemTemplate, and then re-building the item actors with the item_struct info. but again no luck, the array is also empty and using struct also gives me the problem that it can’t be empty, it will always use default values, which makes my inventory say it’s full and can’t pickup any real items that dropped.

I guess I will try populating my itemTemplate with plain variables rather than the item_struct. Then on load, rebuild the itemTemplates based off of the variables. That’s gonna be a lot of work but i guess it’s worth a try, this **** really needs to work :slight_smile:

The short version is that you can not save references. Sure the references are passed to the save game object, but then when you load a new map or restart the game, the references are lost. That’s why, if you check the references, they will be there in the save, but not in the load events.

I too have recently started fiddling with a save/load system for inventory and the like.
As far as I have researched, the consensus is to save the unique properties (probably in specialized structs) of a referenced object, and when loading construct that object and pass in the properties.

I can provide some screen shots of my bp setup if you wish to have an example.

I got it working! :slight_smile: :slight_smile:

I used the Item_Struct to save info about my items, then I did “spawn actor from class” to respawn the items and set back its values.

The reason why it first said my inventory was full, and everything got filled with default items was a stupid bug from my side and had nothing to do with struct filling out default values, I just had to do a is valid check when filling my array to see if there was an item already there.

So glad i figured it out, i’ve been stuck with this saving inventory feature for a week now :frowning:


could you post a Screenshot or a working Version of your saving Setup?

I have the exact same Problem with the inventory. You use, as far i can see, the inventory from the tutorial of Wes Bunn. I try to save to. But i have one Problem.
If i save the Array with object, and the items are in order: Slot1, Slot2, Slot3. All is perfect and loads good. (But i can’t save Array of Texture2d)

But if i move the items, let’s say: Slot1, Slot8, Slot11, then if i save the Array, only two items are saved. So, as soon i move the items and it doesn’t matter how many items
are in the inventory, always are one item missed by saving. For clear: I have 15 Items -> 14 are saved. I have 12 Items -> 11 are saved, and so on.

Could you help me out?


Hey Beregron,

My code is a bit too complex and confusing atm to post screenshots of.

I’d need some screenshots of your code to help you out. but the forum adding images feature seems to be broken atm.
you can send me some screenshots of your code to if you want. I’ll be happy to see if I can help you out.

Hey thank you. As soon as i can, i’ll send you some pics.