USaveGame
#include "GameFramework/SaveGame.h" Description
Base class for save game objects. Subclass it and add UPROPERTY members for every piece of data you want to persist. Use UGameplayStatics::SaveGameToSlot and LoadGameFromSlot to write and read.
Signature
class USaveGame : public UObject Caveats & Gotchas
- • USaveGame itself has no built-in versioning. If you add or rename properties between releases, old save files may deserialize incorrectly. Implement custom version checking.
- • SaveGameToSlot is synchronous and can cause a hitch. For large saves, consider using the async API (AsyncSaveGameToSlot in UE5).
- • Only UPROPERTY-tagged members are serialized — non-UPROPERTY C++ fields are ignored.
- • The 'slot name' is just a file identifier — multiple save files use different slot names. There's no built-in save file management UI.
Example
Define and save a save game C++
// UMySaveGame.h
UCLASS()
class UMySaveGame : public USaveGame
{
GENERATED_BODY()
public:
UPROPERTY()
int32 PlayerLevel = 1;
UPROPERTY()
FVector LastCheckpoint;
};
// Saving:
UMySaveGame* Save = Cast<UMySaveGame>(UGameplayStatics::CreateSaveGameObject(UMySaveGame::StaticClass()));
Save->PlayerLevel = 5;
UGameplayStatics::SaveGameToSlot(Save, TEXT("Slot1"), 0); Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?