Hi there! My game crashes when I try to load data from my custom save class. Specifically, it crashes as soon as I try to run ContainsData(), which simply returns the boolean m_containsData. Help would be much appreciated! Thank you in advance.
// UTMFSaveGame variable declarations in the constructor
UTMFSaveGame::UTMFSaveGame()
{
m_containsData = false;
m_defaultSaveSlotIndex = 10;
m_defaultSaveSlotName = "";
}
void AInteractable::OnInteractableLoaded_Implementation()
{
// Create save object
UTMFSaveGame* saveObject = Cast<UTMFSaveGame>(UGameplayStatics::CreateSaveGameObject(UTMFSaveGame::StaticClass()));
UE_LOG(LogTemp, Error, TEXT("Creating save object"));
// Check if the save object has an instance of the object stored
saveObject = Cast<UTMFSaveGame>(UGameplayStatics::LoadGameFromSlot(saveObject->m_defaultSaveSlotName, saveObject->m_defaultSaveSlotIndex));
UE_LOG(LogTemp, Error, TEXT("Loading save object"));
// Check if the save object has information stored within it
if(saveObject->ContainsData())
{
UE_LOG(LogTemp, Error, TEXT("Save object contains data")); // Crash before this gets logged
// Check to see if information about our interactable is stored
if (FInteractableInfo* loadedInfo = saveObject->GetInteractableInfoMap()->Find(this->GetName()))
{
// We know that we have information stored in the save file - now load this into the game instance
Cast<UTMFGameInstance>(GetGameInstance())->GetInteractableInfoMap()->Add(this->GetName(), *loadedInfo);
UE_LOG(LogTemp, Error, TEXT("Loaded interactable object information"));
}
}
}