Hello, I have implemented save functionality before, exactly as I am doing now, but in a new project. This project is throwing an error when saving, however, it is able to load correctly. When I call
UGameplayStatics::SaveGameToSlot(CurrSaveGame, CurrSlotName, CurrUserIndex);
it steps into Unreal Engine code and fails inside the UGameplayStatics::SaveGameToMemory. Specifically, it fails on line 2024, where it is trying to call SaveGameObject->Serialize(Ar);
This throws an exception:
Exception thrown at 0x00007FFF7E70C5E0 (UE4Editor-Engine.dll) in UE4Editor.exe: 0xC0000005: Access violation reading location 0xFFFFFFFFFFFFFFFF.
Using the call stack, I see that SaveGameToMemory is simply being called by SaveGameToSlot. Where SaveGameObject is my USaveGame*.
This leads me to believe I am setting up my USaveGame* class incorrectly. In my case, the class is called UHHSaveGame. Here is how I have that class setup.
USTRUCT()
struct FActorSaveData
{
GENERATED_BODY()
public:
UPROPERTY()
FName ActorName;
UPROPERTY()
FTransform Transform;
UPROPERTY()
TArray<uint8> ByteData;
};
USTRUCT()
struct FPlayerSaveData
{
GENERATED_BODY()
public:
UPROPERTY()
int32 CandyCount;
};
UCLASS()
class HOWLOWEEN_API UHHSaveGame : public USaveGame
{
GENERATED_BODY()
public:
UPROPERTY()
FPlayerSaveData playerSaveData;
UPROPERTY()
TMap<FName, FActorSaveData> actorSaveData;
};
I am unsure what could be going wrong, if something I have is not serializable or what, but thank you so much for the help!