UGameplayStatics
#include "Kismet/GameplayStatics.h" Description
A Blueprint function library providing static utility functions for common gameplay operations: actor spawning, player access, damage, audio, level loading, and save games. All functions are accessible without a class instance.
Caveats & Gotchas
- • Most functions require a WorldContextObject (typically pass 'this' from an Actor or Component). Passing an invalid context silently returns null or no-ops.
- • These are Blueprint-friendly wrappers. C++ code often has more direct and performant alternatives (e.g. UWorld::SpawnActor instead of the deferred spawn path, GetWorld()->GetFirstPlayerController instead of GetPlayerController(this, 0)).
- • Functions that return AActor* (GetActorOfClass, GetPlayerPawn, etc.) can return null — always validate with IsValid() before use.
Example
Common one-liners C++
// Get player controller (single-player)
APlayerController* PC = UGameplayStatics::GetPlayerController(this, 0);
// Play a sound at a location
UGameplayStatics::PlaySoundAtLocation(this, ExplosionSound, GetActorLocation());
// Load a level
UGameplayStatics::OpenLevel(this, FName("MainMenu")); Functions (15)
Damage 1 ▼
| Access | Type | Name |
|---|---|---|
| public | function | UGameplayStatics::ApplyDamage |
Audio 2 ▼
| Access | Type | Name |
|---|---|---|
| public | function | UGameplayStatics::PlaySound2D |
| public | function | UGameplayStatics::PlaySoundAtLocation |
Utility 8 ▼
| Access | Type | Name |
|---|---|---|
| public | function | UGameplayStatics::ApplyRadialDamage |
| public | function | UGameplayStatics::GetActorOfClass |
| public | function | UGameplayStatics::GetAllActorsOfClass |
| public | function | UGameplayStatics::GetPlayerCharacter |
| public | function | UGameplayStatics::GetPlayerController |
| public | function | UGameplayStatics::GetPlayerPawn |
| public | function | UGameplayStatics::OpenLevel |
| public | function | UGameplayStatics::SpawnActor (Spawn Actor from Class) |
SaveGame 4 ▼
| Access | Type | Name |
|---|---|---|
| public | function | UGameplayStatics::CreateSaveGameObject |
| public | function | UGameplayStatics::DoesSaveGameExist |
| public | function | UGameplayStatics::LoadGameFromSlot |
| public | function | UGameplayStatics::SaveGameToSlot |
See Also
Tags
Version History
Introduced in: unknown
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?