Navigation
API > API/Runtime > API/Runtime/Engine > API/Runtime/Engine/Kismet
Inheritance Hierarchy
- UObjectBase
- UObjectBaseUtility
- UObject
- UBlueprintFunctionLibrary
- UGameplayStatics
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
| Type | Name | Description | |
|---|---|---|---|
UGameplayStatics
(
const FObjectInitializer& ObjectInitializer |
Functions
| Type | Name | Description | |
|---|---|---|---|
| void | ActivateReverbEffect
(
const UObject* WorldContextObject, |
Activates a Reverb Effect without the need for an Audio Volume | |
| void | AnnounceAccessibleString
(
const FString& AnnouncementString |
If accessibility is enabled, have the platform announce a string to the player. | |
| float | ApplyDamage
(
AActor* DamagedActor, |
Hurts the specified actor with generic damage. | |
| float | ApplyPointDamage
(
AActor* DamagedActor, |
Hurts the specified actor with the specified impact. | |
| bool | ApplyRadialDamage
(
const UObject* WorldContextObject, |
Hurt locally authoritative actors within the radius. | |
| bool | ApplyRadialDamageWithFalloff
(
const UObject* WorldContextObject, |
Hurt locally authoritative actors within the radius. | |
| bool | AreAnyListenersWithinRange
(
const UObject* WorldContextObject, |
Determines if any audio listeners are within range of the specified location | |
| bool | Returns whether or not subtitles are currently enabled. | ||
| void | AsyncLoadGameFromSlot
(
const FString& SlotName, |
Schedule an async load of a specific slot. | |
| void | AsyncSaveGameToSlot
(
USaveGame* SaveGameObject, |
Schedule an async save to a specific slot. | |
| AActor * | BeginDeferredActorSpawnFromClass
(
const UObject* WorldContextObject, |
Spawns an instance of an actor class, but does not automatically run its construction script. | |
| AActor * | BeginSpawningActorFromBlueprint
(
const UObject* WorldContextObject, |
Spawns an instance of a blueprint, but does not automatically run its construction script. | |
| bool | Blueprint_PredictProjectilePath_Advanced
(
const UObject* WorldContextObject, |
Predict the arc of a virtual projectile affected by gravity with collision checks along the arc. | |
| bool | Blueprint_PredictProjectilePath_ByObjectType
(
const UObject* WorldContextObject, |
Predict the arc of a virtual projectile affected by gravity with collision checks along the arc. | |
| bool | Blueprint_PredictProjectilePath_ByTraceChannel
(
const UObject* WorldContextObject, |
Predict the arc of a virtual projectile affected by gravity with collision checks along the arc. | |
| bool | BlueprintSuggestProjectileVelocity
(
const UObject* WorldContextObject, |
Calculates an launch velocity for a projectile to hit a specified point. | |
| void | BreakHitResult
(
const FHitResult& Hit, |
Extracts data from a HitResult. | |
| void | CalculateViewProjectionMatricesFromMinimalView
(
const FMinimalViewInfo& MinimalViewInfo, |
Calculate view-projection matrices from a specified MinimalViewInfo and optional custom projection matrix | |
| void | CalculateViewProjectionMatricesFromViewTarget
(
AActor* InViewTarget, |
Calculate view-projection matrices from a specified view target | |
| void | Cancels all currently queued streaming packages | ||
| void | ClearSoundMixClassOverride
(
const UObject* WorldContextObject, |
Clears any existing override of the Sound Class Adjuster in the given Sound Mix | |
| void | ClearSoundMixModifiers
(
const UObject* WorldContextObject |
Clear all sound mix modifiers from the audio system | |
| APlayerController * | CreatePlayer
(
const UObject* WorldContextObject, |
Create a new local player for this game, for cases like local multiplayer. | |
| APlayerController * | CreatePlayerFromPlatformUser
(
const UObject* WorldContextObject, |
Create a new local player for this game, for cases like local multiplayer. | |
| USaveGame * | CreateSaveGameObject
(
TSubclassOf< USaveGame > SaveGameClass |
Create a new, empty SaveGame object to set data on and then pass to SaveGameToSlot. | |
| UAudioComponent * | CreateSound2D
(
const UObject* WorldContextObject, |
This function allows users to create Audio Components in advance of playback with settings specifically for non-spatialized, non-distance-attenuated sounds. | |
| void | DeactivateReverbEffect
(
const UObject* WorldContextObject, |
Deactivates a Reverb Effect that was applied outside of an Audio Volume | |
| bool | DeleteGameInSlot
(
const FString& SlotName, |
Delete a save game in a particular slot. | |
| bool | DeprojectSceneCaptureToWorld
(
ASceneCapture2D const* SceneCapture2D, |
Transforms the given 2D UV coordinate into a 3D world-space point and direction. | |
| bool | DeprojectScreenToWorld
(
APlayerController const* Player, |
Transforms the given 2D screen space coordinate into a 3D world-space point and direction. | |
| bool | DoesSaveGameExist
(
const FString& SlotName, |
See if a save game exists with the specified name. | |
| void | EnableLiveStreaming
(
bool Enable |
Toggle live DVR streaming. | |
| bool | FindCollisionUV
(
const FHitResult& Hit, |
Try and find the UV for a collision impact. | |
| AActor * | FindNearestActor
(
FVector Origin, |
Returns an Actor nearest to Origin from ActorsToCheck array. | |
| AActor * | FinishSpawningActor
(
AActor* Actor, |
'Finish' spawning an actor. This will run the construction script. | |
| void | FlushLevelStreaming
(
const UObject* WorldContextObject |
Flushes level streaming in blocking fashion and returns when all sub-levels are loaded / visible / hidden | |
| void | GetAccurateRealTime
(
int32& Seconds, |
Returns time in seconds since the application was started. | |
| FName | GetActiveSpatialPluginName
(
const UObject* WorldContextObject |
Get currently active Audio Spatialization Plugin name | |
| FVector | GetActorArrayAverageLocation
(
const TArray< AActor* >& Actors |
Find the average location (centroid) of an array of Actors | |
| void | GetActorArrayBounds
(
const TArray< AActor* >& Actors, |
Bind the bounds of an array of Actors | |
| AActor * | GetActorOfClass
(
const UObject* WorldContextObject, |
Find the first Actor in the world of the specified class. | |
| void | GetAllActorsOfClass
(
const UObject* WorldContextObject, |
Find all Actors in the world of the specified class. | |
| void | GetAllActorsOfClassWithTag
(
const UObject* WorldContextObject, |
Find all Actors in the world of the specified class with the specified tag. | |
| void | GetAllActorsWithInterface
(
const UObject* WorldContextObject, |
Find all Actors in the world with the specified interface. | |
| void | GetAllActorsWithTag
(
const UObject* WorldContextObject, |
Find all Actors in the world with the specified tag. | |
| double | GetAudioTimeSeconds
(
const UObject* WorldContextObject |
Returns time in seconds since world was brought up for play, IS stopped when game pauses, NOT dilated/clamped. | |
| TArray< FName > | GetAvailableSpatialPluginNames
(
const UObject* WorldContextObject |
Get list of available Audio Spatialization Plugin names | |
| bool | GetClosestListenerLocation
(
const UObject* WorldContextObject, |
Finds and returns the position of the closest listener to the specified location | |
| FString | GetCurrentLevelName
(
const UObject* WorldContextObject, |
Get the name of the currently-open level. | |
| UReverbEffect * | GetCurrentReverbEffect
(
const UObject* WorldContextObject |
Returns the highest priority reverb settings currently active from any source (Audio Volumes or manual settings). | |
| bool | GetEnableWorldRendering
(
const UObject* WorldContextObject |
Returns the world rendering state | |
| UGameInstance * | GetGameInstance
(
const UObject* WorldContextObject |
Returns the game instance object | |
| AGameModeBase * | GetGameMode
(
const UObject* WorldContextObject |
Returns the current GameModeBase or Null if it can't be retrieved, such as on the client | |
| AGameStateBase * | GetGameState
(
const UObject* WorldContextObject |
Returns the current GameStateBase or Null if it can't be retrieved | |
| float | GetGlobalTimeDilation
(
const UObject* WorldContextObject |
Gets the current global time dilation. | |
| int32 | GetIntOption
(
const FString& Options, |
Find an option in the options string and return it as an integer. | |
| void | GetKeyValue
(
const FString& Pair, |
Break up a key=value pair into its key and value. | |
| int32 | GetMaxAudioChannelCount
(
const UObject* WorldContextObject |
Retrieves the max voice count currently used by the audio engine. | |
| int32 | GetNumLocalPlayerControllers
(
const UObject* WorldContextObject |
Returns the number of fully initialized local players, this will be 0 on dedicated servers. | |
| int32 | GetNumPlayerControllers
(
const UObject* WorldContextObject |
Returns the total number of available player controllers, including remote players when called on a server. | |
| int32 | GetNumPlayerStates
(
const UObject* WorldContextObject |
Returns the number of active player states, there is one player state for every connected player even if they are a remote client. | |
| UClass * | GetObjectClass
(
const UObject* Object |
Returns the class of a passed in Object, will always be valid if Object is not NULL | |
| FString | Returns the string name of the current platform, to perform different behavior based on platform. | ||
| APlayerCameraManager * | GetPlayerCameraManager
(
const UObject* WorldContextObject, |
Returns the camera manager for the Player Controller at the specified player index. | |
| ACharacter * | GetPlayerCharacter
(
const UObject* WorldContextObject, |
Returns the pawn for the player controller at the specified player index, will return null if the pawn is not a character. | |
| APlayerController * | GetPlayerController
(
const UObject* WorldContextObject, |
Returns the player controller found while iterating through the local and available remote player controllers. | |
| APlayerController * | GetPlayerControllerFromID
(
const UObject* WorldContextObject, |
Returns the player controller with the specified physical controller ID. | |
| APlayerController * | GetPlayerControllerFromPlatformUser
(
const UObject* WorldContextObject, |
Returns the player controller with the specified physical controller ID. | |
| int32 | GetPlayerControllerID
(
APlayerController* Player |
Gets what physical controller ID a player is using. This only works for local player controllers. | |
| APawn * | GetPlayerPawn
(
const UObject* WorldContextObject, |
Returns the pawn for the player controller at the specified player index. | |
| APlayerState * | GetPlayerState
(
const UObject* WorldContextObject, |
Returns the player state at the given index in the game state's PlayerArray. | |
| APlayerState * | GetPlayerStateFromUniqueNetId
(
const UObject* WorldContextObject, |
Returns the player state that matches the passed in online id, or null for an invalid one. | |
| double | GetRealTimeSeconds
(
const UObject* WorldContextObject |
Returns time in seconds since world was brought up for play, does NOT stop when game pauses, NOT dilated/clamped | |
| ULevelStreaming * | GetStreamingLevel
(
const UObject* WorldContextObject, |
Returns level streaming object with specified level package name | |
| EPhysicalSurface | GetSurfaceType
(
const FHitResult& Hit |
Returns the EPhysicalSurface type of the given Hit. | |
| double | GetTimeSeconds
(
const UObject* WorldContextObject |
Returns time in seconds since world was brought up for play, adjusted by time dilation and IS stopped when game pauses | |
| double | GetUnpausedTimeSeconds
(
const UObject* WorldContextObject |
Returns time in seconds since world was brought up for play, adjusted by time dilation and IS NOT stopped when game pauses | |
| EMouseCaptureMode | GetViewportMouseCaptureMode
(
const UObject* WorldContextObject |
Returns the current viewport mouse capture mode | |
| void | GetViewProjectionMatrix
(
FMinimalViewInfo DesiredView, |
Returns the View Matrix, Projection Matrix and the View x Projection Matrix for a given view | |
| double | GetWorldDeltaSeconds
(
const UObject* WorldContextObject |
Returns the frame delta time in seconds, adjusted by time dilation. | |
| FIntVector | GetWorldOriginLocation
(
const UObject* WorldContextObject |
Returns world origin current location. | |
| bool | GrabOption
(
FString& Options, |
||
| int32 | GrassOverlappingSphereCount
(
const UObject* WorldContextObject, |
Counts how many grass foliage instances overlap a given sphere. | |
| bool | HasLaunchOption
(
const FString& OptionToCheck |
Checks the commandline to see if the desired option was specified on the commandline (e.g. -demobuild) | |
| bool | Returns whether a key exists in an options string. | ||
| bool | IsAnyLocalPlayerCameraWithinRange
(
const UObject* WorldContextObject, |
Determines if any local player controller's camera is within range of the specified location. | |
| bool | IsGamePaused
(
const UObject* WorldContextObject |
Returns the game's paused state | |
| bool | IsSplitscreenForceDisabled
(
const UObject* WorldContextObject |
Returns the split screen state | |
| bool | LoadDataFromSlot
(
TArray< uint8 >& OutSaveData, |
Load contents from a slot/file into a buffer of save data. | |
| USaveGame * | LoadGameFromMemory
(
const TArray< uint8 >& InSaveData |
Tries to load a SaveGame object from a given array of bytes. | |
| USaveGame * | LoadGameFromSlot
(
const FString& SlotName, |
Load the contents from a given slot. | |
| void | LoadStreamLevel
(
const UObject* WorldContextObject, |
Stream the level (by Name); Calling again before it finishes has no effect | |
| void | LoadStreamLevelBySoftObjectPtr
(
const UObject* WorldContextObject, |
Stream the level (by Object Reference); Calling again before it finishes has no effect | |
| FHitResult | MakeHitResult
(
bool bBlockingHit, |
Create a HitResult struct | |
| bool |
ObjectIsA
(
const UObject* Object, |
Returns whether or not the object passed in is of (or inherits from) the class type. | |
| void | Travel to another level | ||
| void | OpenLevelBySoftObjectPtr
(
const UObject* WorldContextObject, |
Travel to another level | |
| FString | ParseOption
(
FString Options, |
Find an option in the options string and return it. | |
| void | PlayDialogue2D
(
const UObject* WorldContextObject, |
Plays a dialogue directly with no attenuation, perfect for UI. | |
| void | PlayDialogueAtLocation
(
const UObject* WorldContextObject, |
||
| void | PlayDialogueAtLocation
(
const UObject* WorldContextObject, |
Plays a dialogue at the given location. | |
| void | PlaySound2D
(
const UObject* WorldContextObject, |
Plays a sound directly with no attenuation, perfect for UI sounds. | |
| void | PlaySoundAtLocation
(
const UObject* WorldContextObject, |
Plays a sound at the given location. | |
| void | PlaySoundAtLocation
(
const UObject* WorldContextObject, |
||
| void | PlayWorldCameraShake
(
const UObject* WorldContextObject, |
Plays an in-world camera shake that affects all nearby local players, with distance-based attenuation. | |
| void | PopSoundMixModifier
(
const UObject* WorldContextObject, |
Pop a sound mix modifier from the audio system | |
| bool | PredictProjectilePath
(
const UObject* WorldContextObject, |
Predict the arc of a virtual projectile affected by gravity with collision checks along the arc. | |
| void | PrimeAllSoundsInSoundClass
(
USoundClass* InSoundClass |
Primes the sound waves in the given USoundClass, caching the first chunk of streamed audio. | |
| void | PrimeSound
(
USoundBase* InSound |
Primes the sound, caching the first chunk of streamed audio. | |
| bool | ProjectWorldToScreen
(
APlayerController const* Player, |
Transforms the given 3D world-space point into a its 2D screen space coordinate. | |
| void | PushSoundMixModifier
(
const UObject* WorldContextObject, |
Push a sound mix modifier onto the audio system | |
| FVector | RebaseLocalOriginOntoZero
(
UObject* WorldContextObject, |
Returns origin based position for local world location. | |
| FVector | RebaseZeroOriginOntoLocal
(
UObject* WorldContextObject, |
Returns local location for origin based position. | |
| void | RemovePlayer
(
APlayerController* Player, |
Removes a local player from this game. | |
| bool | SaveDataToSlot
(
const TArray< uint8 >& InSaveData, |
Save the contents of the buffer to a platform-specific save slot/file | |
| bool | SaveGameToMemory
(
USaveGame* SaveGameObject, |
Serialize our USaveGame object into a given array of bytes | |
| bool | SaveGameToSlot
(
USaveGame* SaveGameObject, |
Save the contents of the SaveGameObject to a platform-specific save slot/file. | |
| bool | SetActiveSpatialPluginByName
(
const UObject* WorldContextObject, |
Get list of available Audio Spatialization Plugins | |
| void | SetBaseSoundMix
(
const UObject* WorldContextObject, |
Audio Functions ---------------------- | |
| void | SetEnableWorldRendering
(
const UObject* WorldContextObject, |
Enabled rendering of the world | |
| void | SetForceDisableSplitscreen
(
const UObject* WorldContextObject, |
Enables split screen | |
| bool | SetGamePaused
(
const UObject* WorldContextObject, |
Sets the game's paused state | |
| void | SetGlobalListenerFocusParameters
(
const UObject* WorldContextObject, |
Sets the global listener focus parameters, which will scale focus behavior of sounds based on their focus azimuth settings in their attenuation settings. | |
| void | SetGlobalPitchModulation
(
const UObject* WorldContextObject, |
Sets a global pitch modulation scalar that will apply to all non-UI sounds | |
| void | SetGlobalTimeDilation
(
const UObject* WorldContextObject, |
Sets the global time dilation. | |
| void | SetMaxAudioChannelsScaled
(
const UObject* WorldContextObject, |
Sets the max number of voices (also known as "channels") dynamically by percentage. | |
| void | SetPlayerControllerID
(
APlayerController* Player, |
Sets what physical controller ID a player should be using. | |
| void | SetPlayerPlatformUserId
(
APlayerController* PlayerController, |
Sets what platform user id a player should be using. This only works for local player controllers. | |
| void | SetSoundClassDistanceScale
(
const UObject* WorldContextObject, |
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 | |
| void | SetSoundMixClassOverride
(
const UObject* WorldContextObject, |
Overrides the sound class adjuster in the given sound mix. | |
| void | SetSubtitlesEnabled
(
bool bEnabled |
Will set subtitles to be enabled or disabled. | |
| void | SetViewportMouseCaptureMode
(
const UObject* WorldContextObject, |
Sets the current viewport mouse capture mode | |
| void | SetWorldOriginLocation
(
const UObject* WorldContextObject, |
Requests a new location for a world origin. | |
| UDecalComponent * | SpawnDecalAtLocation
(
const UObject* WorldContextObject, |
Spawns a decal at the given location and rotation, fire and forget. Does not replicate. | |
| UDecalComponent * | SpawnDecalAttached
(
UMaterialInterface* DecalMaterial, |
Spawns a decal attached to and following the specified component. Does not replicate. | |
| UAudioComponent * | SpawnDialogue2D
(
const UObject* WorldContextObject, |
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. | |
| UAudioComponent * | SpawnDialogueAtLocation
(
const UObject* WorldContextObject, |
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. | |
| UAudioComponent * | SpawnDialogueAttached
(
UDialogueWave* Dialogue, |
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. | |
| UAudioComponent * | SpawnDialogueAttached
(
UDialogueWave* Dialogue, |
||
| UParticleSystemComponent * | SpawnEmitterAtLocation
(
const UObject* WorldContextObject, |
Plays the specified effect at the given location and rotation, fire and forget. | |
| UParticleSystemComponent * | SpawnEmitterAtLocation
(
const UObject* WorldContextObject, |
Backwards compatible version of SpawnEmitterAttached for C++ without Scale. | |
| UParticleSystemComponent * | SpawnEmitterAtLocation
(
UWorld* World, |
Plays the specified effect at the given location and rotation, fire and forget. | |
| UParticleSystemComponent * | SpawnEmitterAttached
(
UParticleSystem* EmitterTemplate, |
Plays the specified effect attached to and following the specified component. | |
| UParticleSystemComponent * | SpawnEmitterAttached
(
UParticleSystem* EmitterTemplate, |
Backwards compatible version of SpawnEmitterAttached for C++ without Scale. | |
| UForceFeedbackComponent * | SpawnForceFeedbackAtLocation
(
const UObject* WorldContextObject, |
Plays a force feedback effect at the given location. | |
| UForceFeedbackComponent * | SpawnForceFeedbackAttached
(
UForceFeedbackEffect* ForceFeedbackEffect, |
Plays a force feedback effect attached to and following the specified component. | |
| UObject * | SpawnObject
(
TSubclassOf< UObject > ObjectClass, |
Create Object | |
| UAudioComponent * | SpawnSound2D
(
const UObject* WorldContextObject, |
This function allows users to create Audio Components with settings specifically for non-spatialized, non-distance-attenuated sounds. | |
| UAudioComponent * | SpawnSoundAtLocation
(
const UObject* WorldContextObject, |
Spawns a sound at the given location. | |
| UAudioComponent * | SpawnSoundAttached
(
USoundBase* Sound, |
This function allows users to create and play Audio Components attached to a specific Scene Component. | |
| UAudioComponent * | SpawnSoundAttached
(
USoundBase* Sound, |
||
| FMemoryReader | 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. | |
| bool | SuggestProjectileVelocity
(
const UObject* WorldContextObject, |
Native version, has more options than the Blueprint version. | |
| bool | SuggestProjectileVelocity_CustomArc
(
const UObject* WorldContextObject, |
Returns the launch velocity needed for a projectile at rest at StartPos to land on EndPos. | |
| bool | SuggestProjectileVelocity_MovingTarget
(
const UObject* WorldContextObject, |
Returns a launch velocity need for a projectile to hit the TargetActor in TimeToTarget seconds based on the TargetActor's current velocity. | |
| void | UnloadStreamLevel
(
const UObject* WorldContextObject, |
Unload a streamed in level (by Name) | |
| void | UnloadStreamLevelBySoftObjectPtr
(
const UObject* WorldContextObject, |
Unload a streamed in level (by Object Reference) | |
| void | UnRetainAllSoundsInSoundClass
(
USoundClass* InSoundClass |
Iterate through all sound waves and releases handles to retained chunks. |
Deprecated Functions
| Type | Name | Description | |
|---|---|---|---|
| void | GetAccurateRealTime
(
int32& Seconds, |
This method has been deprecated and will be removed. Use the double version instead. |