UGameplayStatics::SpawnObject
#include "Kismet/GameplayStatics.h"
Access: public
Specifiers: staticBlueprintCallable
Description
Creates a new UObject instance of the given class with the specified outer. This is the Blueprint-exposed equivalent of NewObject<T> for non-actor UObjects.
Caveats & Gotchas
- • Marked BlueprintInternalUseOnly — it appears as part of the 'Construct Object from Class' BP node, not as a directly callable node in the event graph.
- • Cannot be used to spawn AActor or UActorComponent subclasses; use SpawnActor for actors and AddComponent for components instead.
- • The created object is not tracked by the world's actor list and will not receive Tick, BeginPlay, or any actor lifecycle events.
Signature
static ENGINE_API UObject* SpawnObject(TSubclassOf<UObject> ObjectClass, UObject* Outer); Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| ObjectClass | TSubclassOf<UObject> | The class of UObject to instantiate. Must be a non-Actor, non-ActorComponent UObject subclass. | — |
| Outer | UObject* | The outer object that owns this new object. Determines garbage collection lifetime. | — |
Return Type
UObject* Example
Construct a save game object in C++ C++
// Prefer NewObject directly in C++; SpawnObject is a Blueprint shim
UMySaveGame* SaveGame = NewObject<UMySaveGame>(GetGameInstance(), UMySaveGame::StaticClass());
if (SaveGame)
{
SaveGame->PlayerName = TEXT("Hero");
UGameplayStatics::SaveGameToSlot(SaveGame, TEXT("Slot1"), 0);
} Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?