UGameplayStatics::SaveGameToSlot
#include "Kismet/GameplayStatics.h"
Access: public
Specifiers: static
Description
Serialises a USaveGame object to disk using the platform's save system. Returns true on success. This is a synchronous, blocking call.
Signature
static ENGINE_API bool SaveGameToSlot(USaveGame* SaveGameObject, const FString& SlotName, const int32 UserIndex) Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| SaveGameObject | USaveGame* | The populated save game object to serialise. | — |
| SlotName | const FString& | String identifier for the save slot (e.g. 'SaveSlot1'). | — |
| UserIndex | int32 | Platform user index for multi-user save separation. Use 0 for single-player. | — |
Return Type
bool Caveats & Gotchas
- • Synchronous and blocking — on platforms with slow storage (console HDDs, some mobile devices) this can cause a visible frame hitch. Use AsyncSaveGameToSlot for non-blocking saves.
- • Only UPROPERTY fields on the USaveGame subclass are serialised. Plain C++ members are silently ignored.
- • SlotName is platform-dependent in its underlying path mapping. Keep slot names short, alphanumeric, and avoid special characters for cross-platform safety.
Example
Save and load player progress C++
// Save
UMyGameSave* SaveData = Cast<UMyGameSave>(
UGameplayStatics::CreateSaveGameObject(UMyGameSave::StaticClass())
);
SaveData->PlayerLevel = CurrentLevel;
SaveData->TotalScore = Score;
bool bSuccess = UGameplayStatics::SaveGameToSlot(SaveData, TEXT("Slot1"), 0);
// Load
UMyGameSave* Loaded = Cast<UMyGameSave>(
UGameplayStatics::LoadGameFromSlot(TEXT("Slot1"), 0)
);
if (Loaded)
{
CurrentLevel = Loaded->PlayerLevel;
} See Also
Tags
Version History
Introduced in: unknown
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?