Struggles to save a Spatial Inventory (UE4)

Hello everyone. I’m sure I’m not the first and not the last with save/load struggles, and I’m hoping that someone will aid me to find a solution I’m looking for. My project uses this spatial inventory tutorial as a template: Unreal Engine - Spatial Inventory Tutorial (4/4) - YouTube
and if I’m not mistaken, it’s mostly object reference based which increases the problematic of mine.

The problem is: If I go about saving the items in the player’s inventory component as is (saving and loading an array of items in the inventory) the variables don’t load correctly because the referenced item, upon loading, exists in the world and it’s variables go to default. (For example, current ammo count/quantity for each particular weapon that player has in the inventory.) Of course If I delete a referenced actor from the world completely - the reference is lost completely and the item isn’t going to show up upon loading.

My presumable solution for a brief moment was: instead of saving the references array - creating an array of separate structures with same attributes upon saving, and when the game loads - constructing a new object for each item with it’s variables and adding it to the inventory. Examples shown below:

Example:


This approach, however, doesn’t work, as for some reason an inventory component refuses to add newly constructed items. The debugged reason being - the component thinks that all of it’s grid slots are busy and there’s no place to input the item.

Pls hulp my sanity is slowly going down.

Problem solved. My approach in the example works completely fine except you need to make sure that your player object and it’s corresponding inventory component are succesfully loaded. What I did is now I just operate the inventory load on the player itself rather than game instance/game mode. If anyone has a better solution for that or better way to deal with it - still please let me or others know for educational purporses.

1 Like

Hey, not a solution, but I was also trying to use this same tutorial as a template but I realized that each item is just an image in your inventory. Did you find a way to make them interactable or? I wanted to allow the player to open up a combobox and select different things to do for each item in their inventory