I am having a problem when trying to use the SaveGame class. I created a custom SaveGame class, that has a member of type “TMap”, which I use to store information about the previous object game state in a struct. I have tried adding objects to the map and it seems to be working fine, as long as I am in the same scene. When I try to access one of the members of the map after loading a new scene (or in my case, the same scene), I get a nullptr when trying to use the same keys to access the maps I made in the previous scene i.e. ContainerIsStored will return false and if I remove it before trying to access the map, the game will crash. Any idea why this may be? Thank you in advance!
// Items stored when saving and changing levels, that need to be reinstantiated
TMap<FString, TArray<FInventoryObjectsStruct>> m_containerItems;
bool UMySaveGame::ContainerIsStored(FString l_containerID)
{
if(m_containerItems.Find(l_containerID) == nullptr)
{
UE_LOG(LogTemp, Error, TEXT("Failed to find container in map!"));
return false;
}
return true;
}