RealDocs

UGameplayStatics::CreateSaveGameObject

function Engine Blueprint Since unknown
#include "Kismet/GameplayStatics.h"
Access: public Specifiers: static

Description

Creates a new instance of a USaveGame subclass with default values. Use to create a fresh save object before populating and passing to SaveGameToSlot.

Signature

static ENGINE_API USaveGame* CreateSaveGameObject(TSubclassOf<USaveGame> SaveGameClass)

Parameters

Name Type Description Default
SaveGameClass TSubclassOf<USaveGame> The USaveGame subclass to instantiate.

Return Type

USaveGame*

Caveats & Gotchas

  • The returned object is not associated with any slot until SaveGameToSlot is called. It exists in memory only.
  • Equivalent to NewObject<UMyGameSave>() in C++ — the UGameplayStatics version is primarily for Blueprint convenience. In C++ you can use NewObject directly.

Example

Create, populate, and save C++
UMyGameSave* NewSave = Cast<UMyGameSave>(
	UGameplayStatics::CreateSaveGameObject(UMyGameSave::StaticClass())
);
NewSave->PlayerName = PlayerName;
NewSave->HighScore  = Score;
UGameplayStatics::SaveGameToSlot(NewSave, TEXT("Slot1"), 0);

Version History

Introduced in: unknown

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.