I doubt TMap is broken, instead it’s likely that your UAHSaveGame pointer is either invalid, or was cleaned up.
How are you holding on to that pointer?
You should have a UPROPERTY holding it somewhere, so it doesn’t get Garbage Collected.
UPROPERTY()
UAHSaveGame* MyCurrentSaveGame; // Because this pointer is a UPROPERTY, it's a "strong reference" and will prevent the object from getting Garbage Collected.
Hi, thanks for response.
Currently, I store UAHSaveGame in my GameInstance class, like
UAHGameInstance : public UPlatformGameInstance
with
private:
UAHSaveGame* GameSave;
Really, i have used it without UPROPERTY macro.
And it seems that macro fixed my bug.
Thanks, you are a lifesaver.
That’s the problem. Your GameSave will get garbage collected because the GC will say “Well, no one is holding on to this - so, nuke it”. You need to mark it as a UPROPERTY. If you don’t want the property to be saved out, just mark it as UPROPERTY(Transient).