The Problem
In Unreal, the main way to save progress across instances of the game and across levels is using a custom SaveGame class. Initially as I was setting it up, I was saving the items using an array of item pointers in the SaveGame class. This worked initially, as when I saved and loaded the current scene, the changes made to the items made for testing were saved and loaded correctly. However, once I moved over to a different map and loaded the item data, it mysteriously disappeared!
The Solution
I began to do some troubleshooting. If I saved the initial scene and then moved to the other scene directly from the editor, the items still wouldn't load. If I started in the second scene and moved to the first, the items also wouldn't load. This made me think initially that it was an issue with scene loading.
My next step was to look through the documentation, and I noticed that data members in a SaveGame class needed to be tagged with a SaveGame tag. I tried that with the items, and once again, did not work. At this point I was considering manually saving each item attribute manually in the SaveGame class and reconstructing them manually, however, another solution showed it's head.
I can't fully take credit for finding it, as Jessie was helping me out while looking at the documentation, and he discovered that a SaveGame class cannot properly store a pointer reference, but they could store a struct. I looked further into what he had found, and saw that the class can store a TsubclassOf type variable, and like that a solution was born.
I created a struct called FItemData, with a boolean that tracks whether an item exists in the current inventory slot, and a TsubclassOf type variable which stores the item type. Then upon saving the game, if an item exists in an inventory slot, the type of the item is stored in the struct and the exist boolean is set to true. Otherwise, the exist boolean is set to false. Then once the game is loaded again, it rebuilds the items using the NewObject function.

The final step was to replace the array of item pointers in the save game class with an array of FItemData structs. And just like that, the items loaded perfectly!


