UGameplayStatics

Static class with useful gameplay utility functions that can be called from both Blueprint and C++

Inheritance Hierarchy

References

Module

Engine

Header

/Engine/Source/Runtime/Engine/Classes/Kismet/GameplayStatics.h

Include

#include "Kismet/GameplayStatics.h"

Syntax

class UGameplayStatics : public UBlueprintFunctionLibrary

Remarks

Static class with useful gameplay utility functions that can be called from both Blueprint and C++

Constructors

Name Description

Public function

UGameplayStatics

(
    const FObjectInitializer& ObjectIn...
)

Functions

Name Description

Public function Static

void

 

ActivateReverbEffect

(
    const UObject* WorldContextObj...,
    UReverbEffect* ReverbEffect,
    FName TagName,
    float Priority,
    float Volume,
    float FadeTime
)

Activates a Reverb Effect without the need for an Audio Volume

Public function Static

void

 

AnnounceAccessibleString

(
    const FString& AnnouncementString
)

If accessibility is enabled, have the platform announce a string to the player.

Public function Static

float

 

ApplyDamage

(
    AActor* DamagedActor,
    float BaseDamage,
    AController* EventInstigator,
    AActor* DamageCauser,
    TSubclassOf< class UDamageType > Da...
)

Hurts the specified actor with generic damage.

Public function Static

float

 

ApplyPointDamage

(
    AActor* DamagedActor,
    float BaseDamage,
    const FVector& HitFromDirection,
    const FHitResult& HitInfo,
    AController* EventInstigator,
    AActor* DamageCauser,
    TSubclassOf< class UDamageType > Da...
)

Hurts the specified actor with the specified impact.

Public function Static

bool

 

ApplyRadialDamage

(
    const UObject* WorldContextObj...,
    float BaseDamage,
    const FVector& Origin,
    float DamageRadius,
    TSubclassOf< class UDamageType > Da...,
    const TArray< AActor* >& Igno...,
    AActor* DamageCauser,
    AController* InstigatedByContr...,
    bool bDoFullDamage,
    ECollisionChannel DamagePreventionC...
)

Hurt locally authoritative actors within the radius.

Public function Static

bool

 

ApplyRadialDamageWithFalloff

(
    const UObject* WorldContextObj...,
    float BaseDamage,
    float MinimumDamage,
    const FVector& Origin,
    float DamageInnerRadius,
    float DamageOuterRadius,
    float DamageFalloff,
    TSubclassOf< class UDamageType > Da...,
    const TArray< AActor* >& Igno...,
    AActor* DamageCauser,
    AController* InstigatedByContr...,
    ECollisionChannel DamagePreventionC...
)

Hurt locally authoritative actors within the radius.

Public function Static

bool

 

AreAnyListenersWithinRange

(
    const UObject* WorldContextObj...,
    const FVector& Location,
    float MaximumRange
)

Determines if any audio listeners are within range of the specified location

Public function Static

bool

 

AreSubtitlesEnabled()

Returns whether or not subtitles are currently enabled.

Public function Static

void

 

AsyncLoadGameFromSlot

(
    const FString& SlotName,
    const int32 UserIndex,
    FAsyncLoadGameFromSlotDelegate Load...
)

Schedule an async load of a specific slot.

Public function Static

void

 

AsyncSaveGameToSlot

(
    USaveGame* SaveGameObject,
    const FString& SlotName,
    const int32 UserIndex,
    FAsyncSaveGameToSlotDelegate SavedD...
)

Schedule an async save to a specific slot.

Public function Static

AActor *

 

BeginDeferredActorSpawnFromClass

(
    const UObject* WorldContextObj...,
    TSubclassOf< AActor > ActorClass,
    const FTransform& SpawnTransform,
    ESpawnActorCollisionHandlingMethod ...,
    AActor* Owner,
    ESpawnActorScaleMethod TransformSca...
)

Spawns an instance of an actor class, but does not automatically run its construction script.

Public function Static

AActor *

 

BeginSpawningActorFromBlueprint

(
    const UObject* WorldContextObj...,
    const UBlueprint* Blueprint,
    const FTransform& SpawnTransform,
    bool bNoCollisionFail
)

Spawns an instance of a blueprint, but does not automatically run its construction script.

Public function Static

bool

 

Blueprint_PredictProjectilePath_Advanced

(
    const UObject* WorldContextObj...,
    const FPredictProjectilePathParams ...,
    FPredictProjectilePathResult& Pred...
)

Predict the arc of a virtual projectile affected by gravity with collision checks along the arc.

Public function Static

bool

 

Blueprint_PredictProjectilePath_ByObjectType

(
    const UObject* WorldContextObj...,
    FHitResult& OutHit,
    TArray< FVector >& OutPathPosition...,
    FVector& OutLastTraceDestination,
    FVector StartPos,
    FVector LaunchVelocity,
    bool bTracePath,
    float ProjectileRadius,
    const TArray< TEnumAsByte< EObjectT...,
    bool bTraceComplex,
    const TArray< AActor* >& Acto...,
    EDrawDebugTrace::Type DrawDebugType,
    float DrawDebugTime,
    float SimFrequency,
    float MaxSimTime,
    float OverrideGravityZ
)

Predict the arc of a virtual projectile affected by gravity with collision checks along the arc.

Public function Static

bool

 

Blueprint_PredictProjectilePath_ByTraceChannel

(
    const UObject* WorldContextObj...,
    FHitResult& OutHit,
    TArray< FVector >& OutPathPosition...,
    FVector& OutLastTraceDestination,
    FVector StartPos,
    FVector LaunchVelocity,
    bool bTracePath,
    float ProjectileRadius,
    TEnumAsByte< ECollisionChannel > Tr...,
    bool bTraceComplex,
    const TArray< AActor* >& Acto...,
    EDrawDebugTrace::Type DrawDebugType,
    float DrawDebugTime,
    float SimFrequency,
    float MaxSimTime,
    float OverrideGravityZ
)

Predict the arc of a virtual projectile affected by gravity with collision checks along the arc.

Public function Static

bool

 

BlueprintSuggestProjectileVelocity

(
    const UObject* WorldContextObj...,
    FVector& TossVelocity,
    FVector StartLocation,
    FVector EndLocation,
    float LaunchSpeed,
    float OverrideGravityZ,
    ESuggestProjVelocityTraceOption::Ty...,
    float CollisionRadius,
    bool bFavorHighArc,
    bool bDrawDebug
)

Calculates an launch velocity for a projectile to hit a specified point.

Public function Static

void

 

BreakHitResult

(
    const FHitResult& Hit,
    bool& bBlockingHit,
    bool& bInitialOverlap,
    float& Time,
    float& Distance,
    FVector& Location,
    FVector& ImpactPoint,
    FVector& Normal,
    FVector& ImpactNormal,
    UPhysicalMaterial*& PhysMat,
    AActor*& HitActor,
    UPrimitiveComponent*& HitCompo...,
    FName& HitBoneName,
    FName& BoneName,
    int32& HitItem,
    int32& ElementIndex,
    int32& FaceIndex,
    FVector& TraceStart,
    FVector& TraceEnd
)

Extracts data from a HitResult.

Public function Static

void

 

CalculateViewProjectionMatricesFromMinimalView

(
    const FMinimalViewInfo& MinimalVie...,
    const TOptional< FMatrix >& Custom...,
    FMatrix& OutViewMatrix,
    FMatrix& OutProjectionMatrix,
    FMatrix& OutViewProjectionMatrix
)

Calculate view-projection matrices from a specified MinimalViewInfo and optional custom projection matrix

Public function Static

void

 

CalculateViewProjectionMatricesFromViewTarget

(
    AActor* InViewTarget,
    FMatrix& OutViewMatrix,
    FMatrix& OutProjectionMatrix,
    FMatrix& OutViewProjectionMatrix
)

Calculate view-projection matrices from a specified view target

Public function Static

void

 

CancelAsyncLoading()

Cancels all currently queued streaming packages

Public function Static

void

 

ClearSoundMixClassOverride

(
    const UObject* WorldContextObj...,
    USoundMix* InSoundMixModifier,
    USoundClass* InSoundClass,
    float FadeOutTime
)

Clears any existing override of the Sound Class Adjuster in the given Sound Mix

Public function Static

void

 

ClearSoundMixModifiers

(
    const UObject* WorldContextObj...
)

Clear all sound mix modifiers from the audio system

Public function Static

APlayerContr...

 

CreatePlayer

(
    const UObject* WorldContextObj...,
    int32 ControllerId,
    bool bSpawnPlayerController
)

Create a new local player for this game, for cases like local multiplayer.

Public function Static

APlayerContr...

 

CreatePlayerFromPlatformUser

(
    const UObject* WorldContextObj...,
    FPlatformUserId UserId,
    bool bSpawnPlayerController
)

Create a new local player for this game, for cases like local multiplayer.

Public function Static

USaveGame &#...

 

CreateSaveGameObject

(
    TSubclassOf< USaveGame > SaveGameCl...
)

Create a new, empty SaveGame object to set data on and then pass to SaveGameToSlot.

Public function Static

UAudioCompon...

 

CreateSound2D

(
    const UObject* WorldContextObj...,
    USoundBase* Sound,
    float VolumeMultiplier,
    float PitchMultiplier,
    float StartTime,
    USoundConcurrency* Concurrency...,
    bool bPersistAcrossLevelTransition,
    bool bAutoDestroy
)

This function allows users to create Audio Components in advance of playback with settings specifically for non-spatialized, non-distance-attenuated sounds.

Public function Static

void

 

DeactivateReverbEffect

(
    const UObject* WorldContextObj...,
    FName TagName
)

Deactivates a Reverb Effect that was applied outside of an Audio Volume

Public function Static

bool

 

DeleteGameInSlot

(
    const FString& SlotName,
    const int32 UserIndex
)

Delete a save game in a particular slot.

Public function Static

bool

 

DeprojectSceneCaptureToWorld

(
    ASceneCapture2D const* SceneCa...,
    const FVector2D& TargetUV,
    FVector& WorldPosition,
    FVector& WorldDirection
)

Transforms the given 2D UV coordinate into a 3D world-space point and direction.

Public function Static

bool

 

DeprojectScreenToWorld

(
    APlayerController const* Playe...,
    const FVector2D& ScreenPosition,
    FVector& WorldPosition,
    FVector& WorldDirection
)

Transforms the given 2D screen space coordinate into a 3D world-space point and direction.

Public function Static

bool

 

DoesSaveGameExist

(
    const FString& SlotName,
    const int32 UserIndex
)

See if a save game exists with the specified name.

Public function Static

void

 

EnableLiveStreaming

(
    bool Enable
)

Toggle live DVR streaming.

Public function Static

bool

 

FindCollisionUV

(
    const FHitResult& Hit,
    int32 UVChannel,
    FVector2D& UV
)

Try and find the UV for a collision impact.

Public function Static

AActor *

 

FindNearestActor

(
    FVector Origin,
    const TArray< AActor* >& Acto...,
    float& Distance
)

Returns an Actor nearest to Origin from ActorsToCheck array.

Public function Static

AActor *

 

FinishSpawningActor

(
    AActor* Actor,
    const FTransform& SpawnTransform,
    ESpawnActorScaleMethod TransformSca...
)

'Finish' spawning an actor. This will run the construction script.

Public function Static

void

 

FlushLevelStreaming

(
    const UObject* WorldContextObj...
)

Flushes level streaming in blocking fashion and returns when all sub-levels are loaded / visible / hidden

Public function Static

void

 

GetAccurateRealTime

(
    int32& Seconds,
    double& PartialSeconds
)

Returns time in seconds since the application was started.

Public function Static

FName

 

GetActiveSpatialPluginName

(
    const UObject* WorldContextObj...
)

Get currently active Audio Spatialization Plugin name

Public function Static

FVector

 

GetActorArrayAverageLocation

(
    const TArray< AActor* >& Acto...
)

Find the average location (centroid) of an array of Actors

Public function Static

void

 

GetActorArrayBounds

(
    const TArray< AActor* >& Acto...,
    bool bOnlyCollidingComponents,
    FVector& Center,
    FVector& BoxExtent
)

Bind the bounds of an array of Actors

Public function Static

AActor *

 

GetActorOfClass

(
    const UObject* WorldContextObj...,
    TSubclassOf< AActor > ActorClass
)

Find the first Actor in the world of the specified class.

Public function Static

void

 

GetAllActorsOfClass

(
    const UObject* WorldContextObj...,
    TSubclassOf< AActor > ActorClass,
    TArray< AActor* >& OutActors
)

Find all Actors in the world of the specified class.

Public function Static

void

 

GetAllActorsOfClassWithTag

(
    const UObject* WorldContextObj...,
    TSubclassOf< AActor > ActorClass,
    FName Tag,
    TArray< AActor* >& OutActors
)

Find all Actors in the world of the specified class with the specified tag.

Public function Static

void

 

GetAllActorsWithInterface

(
    const UObject* WorldContextObj...,
    TSubclassOf< UInterface > Interface,
    TArray< AActor* >& OutActors
)

Find all Actors in the world with the specified interface.

Public function Static

void

 

GetAllActorsWithTag

(
    const UObject* WorldContextObj...,
    FName Tag,
    TArray< AActor* >& OutActors
)

Find all Actors in the world with the specified tag.

Public function Static

double

 

GetAudioTimeSeconds

(
    const UObject* WorldContextObj...
)

Returns time in seconds since world was brought up for play, IS stopped when game pauses, NOT dilated/clamped.

Public function Static

TArray< FNam...

 

GetAvailableSpatialPluginNames

(
    const UObject* WorldContextObj...
)

Get list of available Audio Spatialization Plugin names

Public function Static

bool

 

GetClosestListenerLocation

(
    const UObject* WorldContextObj...,
    const FVector& Location,
    float MaximumRange,
    const bool bAllowAttenuationOverrid...,
    FVector& ListenerPosition
)

Finds and returns the position of the closest listener to the specified location

Public function Static

FString

 

GetCurrentLevelName

(
    const UObject* WorldContextObj...,
    bool bRemovePrefixString
)

Get the name of the currently-open level.

Public function Static

UReverbEffec...

 

GetCurrentReverbEffect

(
    const UObject* WorldContextObj...
)

Returns the highest priority reverb settings currently active from any source (Audio Volumes or manual settings).

Public function Static

bool

 

GetEnableWorldRendering

(
    const UObject* WorldContextObj...
)

Returns the world rendering state

Public function Static

UGameInstanc...

 

GetGameInstance

(
    const UObject* WorldContextObj...
)

Returns the game instance object

Public function Static

AGameModeBas...

 

GetGameMode

(
    const UObject* WorldContextObj...
)

Returns the current GameModeBase or Null if it can't be retrieved, such as on the client

Public function Static

AGameStateBa...

 

GetGameState

(
    const UObject* WorldContextObj...
)

Returns the current GameStateBase or Null if it can't be retrieved

Public function Static

float

 

GetGlobalTimeDilation

(
    const UObject* WorldContextObj...
)

Gets the current global time dilation.

Public function Static

int32

 

GetIntOption

(
    const FString& Options,
    const FString& Key,
    int32 DefaultValue
)

Find an option in the options string and return it as an integer.

Public function Static

void

 

GetKeyValue

(
    const FString& Pair,
    FString& Key,
    FString& Value
)

Break up a key=value pair into its key and value.

Public function Static

int32

 

GetMaxAudioChannelCount

(
    const UObject* WorldContextObj...
)

Retrieves the max voice count currently used by the audio engine.

Public function Static

int32

 

GetNumLocalPlayerControllers

(
    const UObject* WorldContextObj...
)

Returns the number of fully initialized local players, this will be 0 on dedicated servers.

Public function Static

int32

 

GetNumPlayerControllers

(
    const UObject* WorldContextObj...
)

Returns the total number of available player controllers, including remote players when called on a server.

Public function Static

int32

 

GetNumPlayerStates

(
    const UObject* WorldContextObj...
)

Returns the number of active player states, there is one player state for every connected player even if they are a remote client.

Public function Static

UClass *

 

GetObjectClass

(
    const UObject* Object
)

Returns the class of a passed in Object, will always be valid if Object is not NULL

Public function Static

FString

 

GetPlatformName()

Returns the string name of the current platform, to perform different behavior based on platform.

Public function Static

APlayerCamer...

 

GetPlayerCameraManager

(
    const UObject* WorldContextObj...,
    int32 PlayerIndex
)

Returns the camera manager for the Player Controller at the specified player index.

Public function Static

ACharacter &...

 

GetPlayerCharacter

(
    const UObject* WorldContextObj...,
    int32 PlayerIndex
)

Returns the pawn for the player controller at the specified player index, will return null if the pawn is not a character.

Public function Static

APlayerContr...

 

GetPlayerController

(
    const UObject* WorldContextObj...,
    int32 PlayerIndex
)

Returns the player controller found while iterating through the local and available remote player controllers.

Public function Static

APlayerContr...

 

GetPlayerControllerFromID

(
    const UObject* WorldContextObj...,
    int32 ControllerID
)

Returns the player controller with the specified physical controller ID.

Public function Static

APlayerContr...

 

GetPlayerControllerFromPlatformUser

(
    const UObject* WorldContextObj...,
    FPlatformUserId UserId
)

Returns the player controller with the specified physical controller ID.

Public function Static

int32

 

GetPlayerControllerID

(
    APlayerController* Player
)

Gets what physical controller ID a player is using. This only works for local player controllers.

Public function Static

APawn *

 

GetPlayerPawn

(
    const UObject* WorldContextObj...,
    int32 PlayerIndex
)

Returns the pawn for the player controller at the specified player index.

Public function Static

APlayerState...

 

GetPlayerState

(
    const UObject* WorldContextObj...,
    int32 PlayerStateIndex
)

Returns the player state at the given index in the game state's PlayerArray.

Public function Static

APlayerState...

 

GetPlayerStateFromUniqueNetId

(
    const UObject* WorldContextObj...,
    const FUniqueNetIdRepl& UniqueId
)

Returns the player state that matches the passed in online id, or null for an invalid one.

Public function Static

double

 

GetRealTimeSeconds

(
    const UObject* WorldContextObj...
)

Returns time in seconds since world was brought up for play, does NOT stop when game pauses, NOT dilated/clamped

Public function Static

ULevelStream...

 

GetStreamingLevel

(
    const UObject* WorldContextObj...,
    FName PackageName
)

Returns level streaming object with specified level package name

Public function Static

EPhysicalSur...

 

GetSurfaceType

(
    const FHitResult& Hit
)

Returns the EPhysicalSurface type of the given Hit.

Public function Static

double

 

GetTimeSeconds

(
    const UObject* WorldContextObj...
)

Returns time in seconds since world was brought up for play, adjusted by time dilation and IS stopped when game pauses

Public function Static

double

 

GetUnpausedTimeSeconds

(
    const UObject* WorldContextObj...
)

Returns time in seconds since world was brought up for play, adjusted by time dilation and IS NOT stopped when game pauses

Public function Static

EMouseCaptur...

 

GetViewportMouseCaptureMode

(
    const UObject* WorldContextObj...
)

Returns the current viewport mouse capture mode

Public function Static

void

 

GetViewProjectionMatrix

(
    FMinimalViewInfo DesiredView,
    FMatrix& ViewMatrix,
    FMatrix& ProjectionMatrix,
    FMatrix& ViewProjectionMatrix
)

Returns the View Matrix, Projection Matrix and the View x Projection Matrix for a given view

Public function Static

double

 

GetWorldDeltaSeconds

(
    const UObject* WorldContextObj...
)

Returns the frame delta time in seconds, adjusted by time dilation.

Public function Static

FIntVector

 

GetWorldOriginLocation

(
    const UObject* WorldContextObj...
)

Returns world origin current location.

Public function Static

bool

 

GrabOption

(
    FString& Options,
    FString& ResultString
)

Public function Static

int32

 

GrassOverlappingSphereCount

(
    const UObject* WorldContextObj...,
    const UStaticMesh* StaticMesh,
    FVector CenterPosition,
    float Radius
)

Counts how many grass foliage instances overlap a given sphere.

Public function Static

bool

 

HasLaunchOption

(
    const FString& OptionToCheck
)

Checks the commandline to see if the desired option was specified on the commandline (e.g. -demobuild)

Public function Static

bool

 

HasOption

(
    FString Options,
    const FString& InKey
)

Returns whether a key exists in an options string.

Public function Static

bool

 

IsAnyLocalPlayerCameraWithinRange

(
    const UObject* WorldContextObj...,
    const FVector& Location,
    float MaximumRange
)

Determines if any local player controller's camera is within range of the specified location.

Public function Static

bool

 

IsGamePaused

(
    const UObject* WorldContextObj...
)

Returns the game's paused state

Public function Static

bool

 

IsSplitscreenForceDisabled

(
    const UObject* WorldContextObj...
)

Returns the split screen state

Public function Static

bool

 

LoadDataFromSlot

(
    TArray< uint8 >& OutSaveData,
    const FString& SlotName,
    const int32 UserIndex
)

Load contents from a slot/file into a buffer of save data.

Public function Static

USaveGame &#...

 

LoadGameFromMemory

(
    const TArray< uint8 >& InSaveData
)

Tries to load a SaveGame object from a given array of bytes.

Public function Static

USaveGame &#...

 

LoadGameFromSlot

(
    const FString& SlotName,
    const int32 UserIndex
)

Load the contents from a given slot.

Public function Static

void

 

LoadStreamLevel

(
    const UObject* WorldContextObj...,
    FName LevelName,
    bool bMakeVisibleAfterLoad,
    bool bShouldBlockOnLoad,
    FLatentActionInfo LatentInfo
)

Stream the level (by Name); Calling again before it finishes has no effect

Public function Static

void

 

LoadStreamLevelBySoftObjectPtr

(
    const UObject* WorldContextObj...,
    const TSoftObjectPtr< UWorld > Leve...,
    bool bMakeVisibleAfterLoad,
    bool bShouldBlockOnLoad,
    FLatentActionInfo LatentInfo
)

Stream the level (by Object Reference); Calling again before it finishes has no effect

Public function Static

FHitResult

 

MakeHitResult

(
    bool bBlockingHit,
    bool bInitialOverlap,
    float Time,
    float Distance,
    FVector Location,
    FVector ImpactPoint,
    FVector Normal,
    FVector ImpactNormal,
    UPhysicalMaterial* PhysMat,
    AActor* HitActor,
    UPrimitiveComponent* HitCompon...,
    FName HitBoneName,
    FName BoneName,
    int32 HitItem,
    int32 ElementIndex,
    int32 FaceIndex,
    FVector TraceStart,
    FVector TraceEnd
)

Create a HitResult struct

Public function Static

bool

 

ObjectIsA

(
    const UObject* Object,
    TSubclassOf< UObject > ObjectClass
)

Returns whether or not the object passed in is of (or inherits from) the class type.

Public function Static

void

 

OpenLevel

(
    const UObject* WorldContextObj...,
    FName LevelName,
    bool bAbsolute,
    FString Options
)

Travel to another level

Public function Static

void

 

OpenLevelBySoftObjectPtr

(
    const UObject* WorldContextObj...,
    const TSoftObjectPtr< UWorld > Leve...,
    bool bAbsolute,
    FString Options
)

Travel to another level

Public function Static

FString

 

ParseOption

(
    FString Options,
    const FString& Key
)

Find an option in the options string and return it.

Public function Static

void

 

PlayDialogue2D

(
    const UObject* WorldContextObj...,
    UDialogueWave* Dialogue,
    const FDialogueContext& Context,
    float VolumeMultiplier,
    float PitchMultiplier,
    float StartTime
)

Plays a dialogue directly with no attenuation, perfect for UI.

Public function Static

void

 

PlayDialogueAtLocation

(
    const UObject* WorldContextObj...,
    UDialogueWave* Dialogue,
    const FDialogueContext& Context,
    FVector Location,
    float VolumeMultiplier,
    float PitchMultiplier,
    float StartTime,
    USoundAttenuation* Attenuation...
)

Public function Static

void

 

PlayDialogueAtLocation

(
    const UObject* WorldContextObj...,
    UDialogueWave* Dialogue,
    const FDialogueContext& Context,
    FVector Location,
    FRotator Rotation,
    float VolumeMultiplier,
    float PitchMultiplier,
    float StartTime,
    USoundAttenuation* Attenuation...
)

Plays a dialogue at the given location.

Public function Static

void

 

PlaySound2D

(
    const UObject* WorldContextObj...,
    USoundBase* Sound,
    float VolumeMultiplier,
    float PitchMultiplier,
    float StartTime,
    USoundConcurrency* Concurrency...,
    const AActor* OwningActor,
    bool bIsUISound
)

Plays a sound directly with no attenuation, perfect for UI sounds.

Public function Static

void

 

PlaySoundAtLocation

(
    const UObject* WorldContextObj...,
    USoundBase* Sound,
    FVector Location,
    FRotator Rotation,
    float VolumeMultiplier,
    float PitchMultiplier,
    float StartTime,
    USoundAttenuation* Attenuation...,
    USoundConcurrency* Concurrency...,
    const AActor* OwningActor,
    const UInitialActiveSoundParams...
)

Plays a sound at the given location.

Public function Static

void

 

PlaySoundAtLocation

(
    const UObject* WorldContextObj...,
    USoundBase* Sound,
    FVector Location,
    float VolumeMultiplier,
    float PitchMultiplier,
    float StartTime,
    USoundAttenuation* Attenuation...,
    USoundConcurrency* Concurrency...,
    const UInitialActiveSoundParams...
)

Public function Static

void

 

PlayWorldCameraShake

(
    const UObject* WorldContextObj...,
    TSubclassOf< class UCameraShakeBase...,
    FVector Epicenter,
    float InnerRadius,
    float OuterRadius,
    float Falloff,
    bool bOrientShakeTowardsEpicenter
)

Plays an in-world camera shake that affects all nearby local players, with distance-based attenuation.

Public function Static

void

 

PopSoundMixModifier

(
    const UObject* WorldContextObj...,
    USoundMix* InSoundMixModifier
)

Pop a sound mix modifier from the audio system

Public function Static

bool

 

PredictProjectilePath

(
    const UObject* WorldContextObj...,
    const FPredictProjectilePathParams ...,
    FPredictProjectilePathResult& Pred...
)

Predict the arc of a virtual projectile affected by gravity with collision checks along the arc.

Public function Static

void

 

PrimeAllSoundsInSoundClass

(
    USoundClass* InSoundClass
)

Primes the sound waves in the given USoundClass, caching the first chunk of streamed audio.

Public function Static

void

 

PrimeSound

(
    USoundBase* InSound
)

Primes the sound, caching the first chunk of streamed audio.

Public function Static

bool

 

ProjectWorldToScreen

(
    APlayerController const* Playe...,
    const FVector& WorldPosition,
    FVector2D& ScreenPosition,
    bool bPlayerViewportRelative
)

Transforms the given 3D world-space point into a its 2D screen space coordinate.

Public function Static

void

 

PushSoundMixModifier

(
    const UObject* WorldContextObj...,
    USoundMix* InSoundMixModifier
)

Push a sound mix modifier onto the audio system

Public function Static

FVector

 

RebaseLocalOriginOntoZero

(
    UObject* WorldContextObject,
    FVector WorldLocation
)

Returns origin based position for local world location.

Public function Static

FVector

 

RebaseZeroOriginOntoLocal

(
    UObject* WorldContextObject,
    FVector WorldLocation
)

Returns local location for origin based position.

Public function Static

void

 

RemovePlayer

(
    APlayerController* Player,
    bool bDestroyPawn
)

Removes a local player from this game.

Public function Static

bool

 

SaveDataToSlot

(
    const TArray< uint8 >& InSaveData,
    const FString& SlotName,
    const int32 UserIndex
)

Save the contents of the buffer to a platform-specific save slot/file

Public function Static

bool

 

SaveGameToMemory

(
    USaveGame* SaveGameObject,
    TArray< uint8 >& OutSaveData
)

Serialize our USaveGame object into a given array of bytes

Public function Static

bool

 

SaveGameToSlot

(
    USaveGame* SaveGameObject,
    const FString& SlotName,
    const int32 UserIndex
)

Save the contents of the SaveGameObject to a platform-specific save slot/file.

Public function Static

bool

 

SetActiveSpatialPluginByName

(
    const UObject* WorldContextObj...,
    FName InPluginName
)

Get list of available Audio Spatialization Plugins

Public function Static

void

 

SetBaseSoundMix

(
    const UObject* WorldContextObj...,
    USoundMix* InSoundMix
)

Audio Functions ----------------------

Public function Static

void

 

SetEnableWorldRendering

(
    const UObject* WorldContextObj...,
    bool bEnable
)

Enabled rendering of the world

Public function Static

void

 

SetForceDisableSplitscreen

(
    const UObject* WorldContextObj...,
    bool bDisable
)

Enables split screen

Public function Static

bool

 

SetGamePaused

(
    const UObject* WorldContextObj...,
    bool bPaused
)

Sets the game's paused state

Public function Static

void

 

SetGlobalListenerFocusParameters

(
    const UObject* WorldContextObj...,
    float FocusAzimuthScale,
    float NonFocusAzimuthScale,
    float FocusDistanceScale,
    float NonFocusDistanceScale,
    float FocusVolumeScale,
    float NonFocusVolumeScale,
    float FocusPriorityScale,
    float NonFocusPriorityScale
)

Sets the global listener focus parameters, which will scale focus behavior of sounds based on their focus azimuth settings in their attenuation settings.

Public function Static

void

 

SetGlobalPitchModulation

(
    const UObject* WorldContextObj...,
    float PitchModulation,
    float TimeSec
)

Sets a global pitch modulation scalar that will apply to all non-UI sounds

Public function Static

void

 

SetGlobalTimeDilation

(
    const UObject* WorldContextObj...,
    float TimeDilation
)

Sets the global time dilation.

Public function Static

void

 

SetMaxAudioChannelsScaled

(
    const UObject* WorldContextObj...,
    float MaxChannelCountScale
)

Sets the max number of voices (also known as "channels") dynamically by percentage.

Public function Static

void

 

SetPlayerControllerID

(
    APlayerController* Player,
    int32 ControllerId
)

Sets what physical controller ID a player should be using.

Public function Static

void

 

SetPlayerPlatformUserId

(
    APlayerController* PlayerContr...,
    FPlatformUserId UserId
)

Sets what platform user id a player should be using. This only works for local player controllers.

Public function Static

void

 

SetSoundClassDistanceScale

(
    const UObject* WorldContextObj...,
    USoundClass* SoundClass,
    float DistanceAttenuationScale,
    float TimeSec
)

Linearly interpolates the attenuation distance scale value from it's current attenuation distance override value (1.0f it not overridden) to its new attenuation distance override, over the given amount of time

Public function Static

void

 

SetSoundMixClassOverride

(
    const UObject* WorldContextObj...,
    USoundMix* InSoundMixModifier,
    USoundClass* InSoundClass,
    float Volume,
    float Pitch,
    float FadeInTime,
    bool bApplyToChildren
)

Overrides the sound class adjuster in the given sound mix.

Public function Static

void

 

SetSubtitlesEnabled

(
    bool bEnabled
)

Will set subtitles to be enabled or disabled.

Public function Static

void

 

SetViewportMouseCaptureMode

(
    const UObject* WorldContextObj...,
    const EMouseCaptureMode MouseCaptur...
)

Sets the current viewport mouse capture mode

Public function Static

void

 

SetWorldOriginLocation

(
    const UObject* WorldContextObj...,
    FIntVector NewLocation
)

Requests a new location for a world origin.

Public function Static

UDecalCompon...

 

SpawnDecalAtLocation

(
    const UObject* WorldContextObj...,
    UMaterialInterface* DecalMater...,
    FVector DecalSize,
    FVector Location,
    FRotator Rotation,
    float LifeSpan
)

Spawns a decal at the given location and rotation, fire and forget. Does not replicate.

Public function Static

UDecalCompon...

 

SpawnDecalAttached

(
    UMaterialInterface* DecalMater...,
    FVector DecalSize,
    USceneComponent* AttachToCompo...,
    FName AttachPointName,
    FVector Location,
    FRotator Rotation,
    EAttachLocation::Type LocationType,
    float LifeSpan
)

Spawns a decal attached to and following the specified component. Does not replicate.

Public function Static

UAudioCompon...

 

SpawnDialogue2D

(
    const UObject* WorldContextObj...,
    UDialogueWave* Dialogue,
    const FDialogueContext& Context,
    float VolumeMultiplier,
    float PitchMultiplier,
    float StartTime,
    bool bAutoDestroy
)

Spawns a DialogueWave, a special type of Asset that requires Context data in order to resolve a specific SoundBase, which is then passed on to the new Audio Component.

Public function Static

UAudioCompon...

 

SpawnDialogueAtLocation

(
    const UObject* WorldContextObj...,
    UDialogueWave* Dialogue,
    const FDialogueContext& Context,
    FVector Location,
    FRotator Rotation,
    float VolumeMultiplier,
    float PitchMultiplier,
    float StartTime,
    USoundAttenuation* Attenuation...,
    bool bAutoDestroy
)

Spawns a DialogueWave, a special type of Asset that requires Context data in order to resolve a specific SoundBase, which is then passed on to the new Audio Component.

Public function Static

UAudioCompon...

 

SpawnDialogueAttached

(
    UDialogueWave* Dialogue,
    const FDialogueContext& Context,
    USceneComponent* AttachToCompo...,
    FName AttachPointName,
    FVector Location,
    FRotator Rotation,
    EAttachLocation::Type LocationType,
    bool bStopWhenAttachedToDestroyed,
    float VolumeMultiplier,
    float PitchMultiplier,
    float StartTime,
    USoundAttenuation* Attenuation...,
    bool bAutoDestroy
)

Spawns a DialogueWave, a special type of Asset that requires Context data in order to resolve a specific SoundBase, which is then passed on to the new Audio Component.

Public function Static

UAudioCompon...

 

SpawnDialogueAttached

(
    UDialogueWave* Dialogue,
    const FDialogueContext& Context,
    USceneComponent* AttachToCompo...,
    FName AttachPointName,
    FVector Location,
    EAttachLocation::Type LocationType,
    bool bStopWhenAttachedToDestroyed,
    float VolumeMultiplier,
    float PitchMultiplier,
    float StartTime,
    USoundAttenuation* Attenuation...,
    bool bAutoDestroy
)

Public function Static

UParticleSys...

 

SpawnEmitterAtLocation

(
    const UObject* WorldContextObj...,
    UParticleSystem* EmitterTempla...,
    FVector Location,
    FRotator Rotation,
    FVector Scale,
    bool bAutoDestroy,
    EPSCPoolMethod PoolingMethod,
    bool bAutoActivateSystem
)

Plays the specified effect at the given location and rotation, fire and forget.

Public function Static

UParticleSys...

 

SpawnEmitterAtLocation

(
    const UObject* WorldContextObj...,
    UParticleSystem* EmitterTempla...,
    FVector Location,
    FRotator Rotation,
    bool bAutoDestroy,
    EPSCPoolMethod PoolingMethod,
    bool bAutoActivateSystem
)

Backwards compatible version of SpawnEmitterAttached for C++ without Scale.

Public function Static

UParticleSys...

 

SpawnEmitterAtLocation

(
    UWorld* World,
    UParticleSystem* EmitterTempla...,
    const FTransform& SpawnTransform,
    bool bAutoDestroy,
    EPSCPoolMethod PoolingMethod,
    bool bAutoActivate
)

Plays the specified effect at the given location and rotation, fire and forget.

Public function Static

UParticleSys...

 

SpawnEmitterAttached

(
    UParticleSystem* EmitterTempla...,
    USceneComponent* AttachToCompo...,
    FName AttachPointName,
    FVector Location,
    FRotator Rotation,
    FVector Scale,
    EAttachLocation::Type LocationType,
    bool bAutoDestroy,
    EPSCPoolMethod PoolingMethod,
    bool bAutoActivate
)

Plays the specified effect attached to and following the specified component.

Public function Static

UParticleSys...

 

SpawnEmitterAttached

(
    UParticleSystem* EmitterTempla...,
    USceneComponent* AttachToCompo...,
    FName AttachPointName,
    FVector Location,
    FRotator Rotation,
    EAttachLocation::Type LocationType,
    bool bAutoDestroy,
    EPSCPoolMethod PoolingMethod,
    bool bAutoActivate
)

Backwards compatible version of SpawnEmitterAttached for C++ without Scale.

Public function Static

UForceFeedba...

 

SpawnForceFeedbackAtLocation

(
    const UObject* WorldContextObj...,
    UForceFeedbackEffect* ForceFee...,
    FVector Location,
    FRotator Rotation,
    bool bLooping,
    float IntensityMultiplier,
    float StartTime,
    UForceFeedbackAttenuation* Att...,
    bool bAutoDestroy
)

Plays a force feedback effect at the given location.

Public function Static

UForceFeedba...

 

SpawnForceFeedbackAttached

(
    UForceFeedbackEffect* ForceFee...,
    USceneComponent* AttachToCompo...,
    FName AttachPointName,
    FVector Location,
    FRotator Rotation,
    EAttachLocation::Type LocationType,
    bool bStopWhenAttachedToDestroyed,
    bool bLooping,
    float IntensityMultiplier,
    float StartTime,
    UForceFeedbackAttenuation* Att...,
    bool bAutoDestroy
)

Plays a force feedback effect attached to and following the specified component.

Public function Static

UObject *...

 

SpawnObject

(
    TSubclassOf< UObject > ObjectClass,
    UObject* Outer
)

Create Object

Public function Static

UAudioCompon...

 

SpawnSound2D

(
    const UObject* WorldContextObj...,
    USoundBase* Sound,
    float VolumeMultiplier,
    float PitchMultiplier,
    float StartTime,
    USoundConcurrency* Concurrency...,
    bool bPersistAcrossLevelTransition,
    bool bAutoDestroy
)

This function allows users to create Audio Components with settings specifically for non-spatialized, non-distance-attenuated sounds.

Public function Static

UAudioCompon...

 

SpawnSoundAtLocation

(
    const UObject* WorldContextObj...,
    USoundBase* Sound,
    FVector Location,
    FRotator Rotation,
    float VolumeMultiplier,
    float PitchMultiplier,
    float StartTime,
    USoundAttenuation* Attenuation...,
    USoundConcurrency* Concurrency...,
    bool bAutoDestroy
)

Spawns a sound at the given location.

Public function Static

UAudioCompon...

 

SpawnSoundAttached

(
    USoundBase* Sound,
    USceneComponent* AttachToCompo...,
    FName AttachPointName,
    FVector Location,
    FRotator Rotation,
    EAttachLocation::Type LocationType,
    bool bStopWhenAttachedToDestroyed,
    float VolumeMultiplier,
    float PitchMultiplier,
    float StartTime,
    USoundAttenuation* Attenuation...,
    USoundConcurrency* Concurrency...,
    bool bAutoDestroy
)

This function allows users to create and play Audio Components attached to a specific Scene Component.

Public function Static

UAudioCompon...

 

SpawnSoundAttached

(
    USoundBase* Sound,
    USceneComponent* AttachToCompo...,
    FName AttachPointName,
    FVector Location,
    EAttachLocation::Type LocationType,
    bool bStopWhenAttachedToDestroyed,
    float VolumeMultiplier,
    float PitchMultiplier,
    float StartTime,
    USoundAttenuation* Attenuation...,
    USoundConcurrency* Concurrency...,
    bool bAutoDestroy
)

Public function Static

FMemoryReade...

 

StripSaveGameHeader

(
    const TArray< uint8 >& SaveData
)

Takes the provided buffer and consumes it, parsing past the internal header data, returning a MemoryReader that has: 1) been set up with all the related header information, and 2) offset to where tagged USaveGame object serialization begins. NOTE: that the returned object has a reference to the supplied data - scope them accordingly.

Public function Static

bool

 

SuggestProjectileVelocity

(
    const UObject* WorldContextObj...,
    FVector& TossVelocity,
    FVector StartLocation,
    FVector EndLocation,
    float TossSpeed,
    bool bHighArc,
    float CollisionRadius,
    float OverrideGravityZ,
    ESuggestProjVelocityTraceOption::Ty...,
    const FCollisionResponseParams& Re...,
    const TArray< AActor* >& Acto...,
    bool bDrawDebug
)

Native version, has more options than the Blueprint version.

Public function Static

bool

 

SuggestProjectileVelocity_CustomArc

(
    const UObject* WorldContextObj...,
    FVector& OutLaunchVelocity,
    FVector StartPos,
    FVector EndPos,
    float OverrideGravityZ,
    float ArcParam
)

Returns the launch velocity needed for a projectile at rest at StartPos to land on EndPos.

Public function Static

bool

 

SuggestProjectileVelocity_MovingTarget

(
    const UObject* WorldContextObj...,
    FVector& OutLaunchVelocity,
    FVector ProjectileStartLocation,
    AActor* TargetActor,
    FVector TargetLocationOffset,
    double GravityZOverride,
    double TimeToTarget,
    EDrawDebugTrace::Type DrawDebugType,
    float DrawDebugTime,
    FLinearColor DrawDebugColor
)

Returns a launch velocity need for a projectile to hit the TargetActor in TimeToTarget seconds based on the TargetActor's current velocity.

Public function Static

void

 

UnloadStreamLevel

(
    const UObject* WorldContextObj...,
    FName LevelName,
    FLatentActionInfo LatentInfo,
    bool bShouldBlockOnUnload
)

Unload a streamed in level (by Name)

Public function Static

void

 

UnloadStreamLevelBySoftObjectPtr

(
    const UObject* WorldContextObj...,
    const TSoftObjectPtr< UWorld > Leve...,
    FLatentActionInfo LatentInfo,
    bool bShouldBlockOnUnload
)

Unload a streamed in level (by Object Reference)

Public function Static

void

 

UnRetainAllSoundsInSoundClass

(
    USoundClass* InSoundClass
)

Iterate through all sound waves and releases handles to retained chunks.

Deprecated Functions

Name Description

Public function Static

void

 

GetAccurateRealTime

(
    int32& Seconds,
    float& PartialSeconds
)

This method has been deprecated and will be removed. Use the double version instead.

Help shape the future of Unreal Engine documentation! Tell us how we're doing so we can serve you better.
Take our survey
Cancel