engine
 
载入中...
搜索中...
未找到
静态 Public 成员函数 | 所有成员列表
UGameplayStatics类 参考

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

#include <GameplayStatics.h>

继承自 UBlueprintFunctionLibrary .

静态 Public 成员函数

static void ActivateReverbEffect (const UObject *WorldContextObject, class UReverbEffect *ReverbEffect, FName TagName, float Priority=0.f, float Volume=0.5f, float FadeTime=2.f)
 Activates a Reverb Effect without the need for a volume 更多...
 
static void AnnounceAccessibleString (const FString &AnnouncementString)
 If accessibility is enabled, have the platform announce a string to the player. 更多...
 
static bool AreAnyListenersWithinRange (const UObject *WorldContextObject, const FVector &Location, float MaximumRange)
 Determines if any audio listeners are within range of the specified location 更多...
 
static bool AreSubtitlesEnabled ()
 Returns whether or not subtitles are currently enabled. 更多...
 
static void AsyncLoadGameFromSlot (const FString &SlotName, const int32 UserIndex, FAsyncLoadGameFromSlotDelegate LoadedDelegate)
 Schedule an async load of a specific slot. 更多...
 
static void AsyncSaveGameToSlot (USaveGame *SaveGameObject, const FString &SlotName, const int32 UserIndex, FAsyncSaveGameToSlotDelegate SavedDelegate=FAsyncSaveGameToSlotDelegate())
 Schedule an async save to a specific slot. 更多...
 
static bool Blueprint_PredictProjectilePath_Advanced (const UObject *WorldContextObject, const FPredictProjectilePathParams &PredictParams, FPredictProjectilePathResult &PredictResult)
 Predict the arc of a virtual projectile affected by gravity with collision checks along the arc. 更多...
 
static bool Blueprint_PredictProjectilePath_ByObjectType (const UObject *WorldContextObject, FHitResult &OutHit, TArray< FVector > &OutPathPositions, FVector &OutLastTraceDestination, FVector StartPos, FVector LaunchVelocity, bool bTracePath, float ProjectileRadius, const TArray< TEnumAsByte< EObjectTypeQuery > > &ObjectTypes, bool bTraceComplex, const TArray< AActor * > &ActorsToIgnore, EDrawDebugTrace::Type DrawDebugType, float DrawDebugTime, float SimFrequency=15.f, float MaxSimTime=2.f, float OverrideGravityZ=0)
 Predict the arc of a virtual projectile affected by gravity with collision checks along the arc. 更多...
 
static bool Blueprint_PredictProjectilePath_ByTraceChannel (const UObject *WorldContextObject, FHitResult &OutHit, TArray< FVector > &OutPathPositions, FVector &OutLastTraceDestination, FVector StartPos, FVector LaunchVelocity, bool bTracePath, float ProjectileRadius, TEnumAsByte< ECollisionChannel > TraceChannel, bool bTraceComplex, const TArray< AActor * > &ActorsToIgnore, EDrawDebugTrace::Type DrawDebugType, float DrawDebugTime, float SimFrequency=15.f, float MaxSimTime=2.f, float OverrideGravityZ=0)
 Predict the arc of a virtual projectile affected by gravity with collision checks along the arc. 更多...
 
static bool BlueprintSuggestProjectileVelocity (const UObject *WorldContextObject, FVector &TossVelocity, FVector StartLocation, FVector EndLocation, float LaunchSpeed, float OverrideGravityZ, ESuggestProjVelocityTraceOption::Type TraceOption, float CollisionRadius, bool bFavorHighArc, bool bDrawDebug)
 Calculates an launch velocity for a projectile to hit a specified point. 更多...
 
static void BreakHitResult (const struct FHitResult &Hit, bool &bBlockingHit, bool &bInitialOverlap, float &Time, float &Distance, FVector &Location, FVector &ImpactPoint, FVector &Normal, FVector &ImpactNormal, class UPhysicalMaterial *&PhysMat, class AActor *&HitActor, class UPrimitiveComponent *&HitComponent, FName &HitBoneName, int32 &HitItem, int32 &FaceIndex, FVector &TraceStart, FVector &TraceEnd)
 Extracts data from a HitResult. 更多...
 
static void CalculateViewProjectionMatricesFromMinimalView (const FMinimalViewInfo &MinimalViewInfo, const TOptional< FMatrix > &CustomProjectionMatrix, FMatrix &OutViewMatrix, FMatrix &OutProjectionMatrix, FMatrix &OutViewProjectionMatrix)
 Calculate view-projection matrices from a specified MinimalViewInfo and optional custom projection matrix
 
static void CalculateViewProjectionMatricesFromViewTarget (AActor *InViewTarget, FMatrix &OutViewMatrix, FMatrix &OutProjectionMatrix, FMatrix &OutViewProjectionMatrix)
 Calculate view-projection matrices from a specified view target
 
static void ClearSoundMixClassOverride (const UObject *WorldContextObject, class USoundMix *InSoundMixModifier, class USoundClass *InSoundClass, float FadeOutTime=1.0f)
 Clears the override of the sound class adjuster in the given sound mix. 更多...
 
static void ClearSoundMixModifiers (const UObject *WorldContextObject)
 Clear all sound mix modifiers from the audio system
 
static USaveGame * CreateSaveGameObject (TSubclassOf< USaveGame > SaveGameClass)
 Create a new, empty SaveGame object to set data on and then pass to SaveGameToSlot. 更多...
 
static UAudioComponent * CreateSound2D (const UObject *WorldContextObject, USoundBase *Sound, float VolumeMultiplier=1.f, float PitchMultiplier=1.f, float StartTime=0.f, USoundConcurrency *ConcurrencySettings=nullptr, bool bPersistAcrossLevelTransition=false, bool bAutoDestroy=true)
 Creates a sound with no attenuation, perfect for UI sounds. 更多...
 
static void DeactivateReverbEffect (const UObject *WorldContextObject, FName TagName)
 Deactivates a Reverb Effect not applied by a volume 更多...
 
static bool DeleteGameInSlot (const FString &SlotName, const int32 UserIndex)
 Delete a save game in a particular slot. 更多...
 
static bool DeprojectScreenToWorld (APlayerController const *Player, const FVector2D &ScreenPosition, FVector &WorldPosition, FVector &WorldDirection)
 Transforms the given 2D screen space coordinate into a 3D world-space point and direction. 更多...
 
static bool DoesSaveGameExist (const FString &SlotName, const int32 UserIndex)
 See if a save game exists with the specified name. 更多...
 
static void EnableLiveStreaming (bool Enable)
 Toggle live DVR streaming. 更多...
 
static bool FindCollisionUV (const struct FHitResult &Hit, int32 UVChannel, FVector2D &UV)
 Try and find the UV for a collision impact. 更多...
 
static void GetAccurateRealTime (const UObject *WorldContextObject, int32 &Seconds, float &PartialSeconds)
 Returns time in seconds since the application was started. 更多...
 
static float GetAudioTimeSeconds (const UObject *WorldContextObject)
 Returns time in seconds since world was brought up for play, IS stopped when game pauses, NOT dilated/clamped.
 
static bool GetClosestListenerLocation (const UObject *WorldContextObject, const FVector &Location, float MaximumRange, const bool bAllowAttenuationOverride, FVector &ListenerPosition)
 Finds and returns the position of the closest listener to the specified location 更多...
 
static class UReverbEffect * GetCurrentReverbEffect (const UObject *WorldContextObject)
 Returns the highest priority reverb settings currently active from any source (volumes or manual setting).
 
static int32 GetIntOption (const FString &Options, const FString &Key, int32 DefaultValue)
 Find an option in the options string and return it as an integer. 更多...
 
static void GetKeyValue (const FString &Pair, FString &Key, FString &Value)
 Break up a key=value pair into its key and value. 更多...
 
static int32 GetMaxAudioChannelCount (const UObject *WorldContextObject)
 Retrieves the max voice count currently used by the audio engine.
 
static FString GetPlatformName ()
 Returns the string name of the current platform, to perform different behavior based on platform. 更多...
 
static float GetRealTimeSeconds (const UObject *WorldContextObject)
 Returns time in seconds since world was brought up for play, does NOT stop when game pauses, NOT dilated/clamped
 
static EPhysicalSurface GetSurfaceType (const struct FHitResult &Hit)
 Returns the EPhysicalSurface type of the given Hit. 更多...
 
static float 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
 
static float 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
 
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 更多...
 
static float GetWorldDeltaSeconds (const UObject *WorldContextObject)
 Returns the frame delta time in seconds, adjusted by time dilation.
 
static FIntVector GetWorldOriginLocation (const UObject *WorldContextObject)
 Returns world origin current location.
 
static int32 GrassOverlappingSphereCount (const UObject *WorldContextObject, const UStaticMesh *StaticMesh, FVector CenterPosition, float Radius)
 Counts how many grass foliage instances overlap a given sphere. 更多...
 
static bool HasLaunchOption (const FString &OptionToCheck)
 Checks the commandline to see if the desired option was specified on the commandline (e.g. 更多...
 
static bool HasOption (FString Options, const FString &InKey)
 Returns whether a key exists in an options string. 更多...
 
static bool LoadDataFromSlot (TArray< uint8 > &OutSaveData, const FString &SlotName, const int32 UserIndex)
 Load contents from a slot/file into a buffer of save data. 更多...
 
static USaveGame * LoadGameFromMemory (const TArray< uint8 > &InSaveData)
 Tries to load a SaveGame object from a given array of bytes. 更多...
 
static USaveGame * LoadGameFromSlot (const FString &SlotName, const int32 UserIndex)
 Load the contents from a given slot. 更多...
 
static FHitResult MakeHitResult (bool bBlockingHit, bool bInitialOverlap, float Time, float Distance, FVector Location, FVector ImpactPoint, FVector Normal, FVector ImpactNormal, class UPhysicalMaterial *PhysMat, class AActor *HitActor, class UPrimitiveComponent *HitComponent, FName HitBoneName, int32 HitItem, int32 FaceIndex, FVector TraceStart, FVector TraceEnd)
 Create a HitResult struct 更多...
 
static FString ParseOption (FString Options, const FString &Key)
 Find an option in the options string and return it. 更多...
 
static void PlayDialogue2D (const UObject *WorldContextObject, UDialogueWave *Dialogue, const struct FDialogueContext &Context, float VolumeMultiplier=1.f, float PitchMultiplier=1.f, float StartTime=0.f)
 Plays a dialogue directly with no attenuation, perfect for UI. 更多...
 
static void PlayDialogueAtLocation (const UObject *WorldContextObject, class UDialogueWave *Dialogue, const FDialogueContext &Context, FVector Location, FRotator Rotation, float VolumeMultiplier=1.f, float PitchMultiplier=1.f, float StartTime=0.f, USoundAttenuation *AttenuationSettings=nullptr)
 Plays a dialogue at the given location. 更多...
 
static void PlaySound2D (const UObject *WorldContextObject, USoundBase *Sound, float VolumeMultiplier=1.f, float PitchMultiplier=1.f, float StartTime=0.f, USoundConcurrency *ConcurrencySettings=nullptr, AActor *OwningActor=nullptr, bool bIsUISound=true)
 Plays a sound directly with no attenuation, perfect for UI sounds. 更多...
 
static void PlaySoundAtLocation (const UObject *WorldContextObject, USoundBase *Sound, FVector Location, FRotator Rotation, float VolumeMultiplier=1.f, float PitchMultiplier=1.f, float StartTime=0.f, class USoundAttenuation *AttenuationSettings=nullptr, USoundConcurrency *ConcurrencySettings=nullptr, AActor *OwningActor=nullptr)
 Plays a sound at the given location. 更多...
 
static void PopSoundMixModifier (const UObject *WorldContextObject, class USoundMix *InSoundMixModifier)
 Pop a sound mix modifier from the audio system
 
static bool PredictProjectilePath (const UObject *WorldContextObject, const FPredictProjectilePathParams &PredictParams, FPredictProjectilePathResult &PredictResult)
 Predict the arc of a virtual projectile affected by gravity with collision checks along the arc. 更多...
 
static bool PredictProjectilePath (const UObject *WorldContextObject, FHitResult &OutHit, TArray< FVector > &OutPathPositions, FVector &OutLastTraceDestination, FVector StartPos, FVector LaunchVelocity, bool bTracePath, float ProjectileRadius, const TArray< TEnumAsByte< EObjectTypeQuery > > &ObjectTypes, bool bTraceComplex, const TArray< AActor * > &ActorsToIgnore, EDrawDebugTrace::Type DrawDebugType, float DrawDebugTime, float SimFrequency=15.f, float MaxSimTime=2.f, float OverrideGravityZ=0)
 Deprecated version, use version with input/output struct params instead.
 
static void PrimeSound (USoundBase *InSound)
 Primes the sound, caching the first chunk of streamed audio.
 
static bool ProjectWorldToScreen (APlayerController const *Player, const FVector &WorldPosition, FVector2D &ScreenPosition, bool bPlayerViewportRelative=false)
 Transforms the given 3D world-space point into a its 2D screen space coordinate. 更多...
 
static void PushSoundMixModifier (const UObject *WorldContextObject, class USoundMix *InSoundMixModifier)
 Push a sound mix modifier onto the audio system
 
static FVector RebaseLocalOriginOntoZero (UObject *WorldContextObject, FVector WorldLocation)
 Returns origin based position for local world location.
 
static FVector RebaseZeroOriginOntoLocal (UObject *WorldContextObject, FVector WorldLocation)
 Returns local location for origin based position.
 
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 更多...
 
static bool SaveGameToMemory (USaveGame *SaveGameObject, TArray< uint8 > &OutSaveData)
 Serialize our USaveGame object into a given array of bytes 更多...
 
static bool SaveGameToSlot (USaveGame *SaveGameObject, const FString &SlotName, const int32 UserIndex)
 Save the contents of the SaveGameObject to a platform-specific save slot/file. 更多...
 
static void SetBaseSoundMix (const UObject *WorldContextObject, class USoundMix *InSoundMix)
 Set the sound mix of the audio system for special EQing
 
static void SetGlobalListenerFocusParameters (const UObject *WorldContextObject, float FocusAzimuthScale=1.0f, float NonFocusAzimuthScale=1.0f, float FocusDistanceScale=1.0f, float NonFocusDistanceScale=1.0f, float FocusVolumeScale=1.0f, float NonFocusVolumeScale=1.0f, float FocusPriorityScale=1.0f, float NonFocusPriorityScale=1.0f)
 Sets the global listener focus parameters which will scale focus behavior of sounds based on their focus azimuth settings in their attenuation settings. 更多...
 
static void SetGlobalPitchModulation (const UObject *WorldContextObject, float PitchModulation, float TimeSec)
 Sets a global pitch modulation scalar that will apply to all non-UI sounds 更多...
 
static void SetMaxAudioChannelsScaled (const UObject *WorldContextObject, float MaxChannelCountScale)
 Sets the max number of voices (also known as "channels") dynamically by percentage. 更多...
 
static void SetSoundClassDistanceScale (const UObject *WorldContextObject, USoundClass *SoundClass, float DistanceAttenuationScale, float TimeSec=0.0f)
 Sets attenuation distance scale value on the sound class over the given amount of time from it's current attenuation distance override value (1.0f it not overridden). 更多...
 
static void SetSoundMixClassOverride (const UObject *WorldContextObject, class USoundMix *InSoundMixModifier, class USoundClass *InSoundClass, float Volume=1.0f, float Pitch=1.0f, float FadeInTime=1.0f, bool bApplyToChildren=true)
 Overrides the sound class adjuster in the given sound mix. 更多...
 
static void SetSubtitlesEnabled (bool bEnabled)
 Will set subtitles to be enabled or disabled. 更多...
 
static void SetWorldOriginLocation (const UObject *WorldContextObject, FIntVector NewLocation)
 Requests a new location for a world origin.
 
static UDecalComponent * SpawnDecalAtLocation (const UObject *WorldContextObject, class UMaterialInterface *DecalMaterial, FVector DecalSize, FVector Location, FRotator Rotation=FRotator(-90, 0, 0), float LifeSpan=0)
 Spawns a decal at the given location and rotation, fire and forget. 更多...
 
static UDecalComponent * SpawnDecalAttached (class UMaterialInterface *DecalMaterial, FVector DecalSize, class USceneComponent *AttachToComponent, FName AttachPointName=NAME_None, FVector Location=FVector(ForceInit), FRotator Rotation=FRotator::ZeroRotator, EAttachLocation::Type LocationType=EAttachLocation::KeepRelativeOffset, float LifeSpan=0)
 Spawns a decal attached to and following the specified component. 更多...
 
static UAudioComponent * SpawnDialogue2D (const UObject *WorldContextObject, UDialogueWave *Dialogue, const struct FDialogueContext &Context, float VolumeMultiplier=1.f, float PitchMultiplier=1.f, float StartTime=0.f, bool bAutoDestroy=true)
 Spawns a dialogue with no attenuation, perfect for UI. 更多...
 
static UAudioComponent * SpawnDialogueAtLocation (const UObject *WorldContextObject, UDialogueWave *Dialogue, const struct FDialogueContext &Context, FVector Location, FRotator Rotation=FRotator::ZeroRotator, float VolumeMultiplier=1.f, float PitchMultiplier=1.f, float StartTime=0.f, USoundAttenuation *AttenuationSettings=nullptr, bool bAutoDestroy=true)
 Plays a dialogue at the given location. 更多...
 
static UAudioComponent * SpawnDialogueAttached (UDialogueWave *Dialogue, const FDialogueContext &Context, USceneComponent *AttachToComponent, FName AttachPointName=NAME_None, FVector Location=FVector(ForceInit), FRotator Rotation=FRotator::ZeroRotator, EAttachLocation::Type LocationType=EAttachLocation::KeepRelativeOffset, bool bStopWhenAttachedToDestroyed=false, float VolumeMultiplier=1.f, float PitchMultiplier=1.f, float StartTime=0.f, USoundAttenuation *AttenuationSettings=nullptr, bool bAutoDestroy=true)
 Spawns a dialogue attached to and following the specified component. 更多...
 
static UParticleSystemComponent * SpawnEmitterAttached (class UParticleSystem *EmitterTemplate, class USceneComponent *AttachToComponent, FName AttachPointName=NAME_None, FVector Location=FVector(ForceInit), FRotator Rotation=FRotator::ZeroRotator, FVector Scale=FVector(1.f), EAttachLocation::Type LocationType=EAttachLocation::KeepRelativeOffset, bool bAutoDestroy=true, EPSCPoolMethod PoolingMethod=EPSCPoolMethod::None, bool bAutoActivate=true)
 Plays the specified effect attached to and following the specified component. 更多...
 
static UForceFeedbackComponent * SpawnForceFeedbackAtLocation (const UObject *WorldContextObject, UForceFeedbackEffect *ForceFeedbackEffect, FVector Location, FRotator Rotation=FRotator::ZeroRotator, bool bLooping=false, float IntensityMultiplier=1.f, float StartTime=0.f, UForceFeedbackAttenuation *AttenuationSettings=nullptr, bool bAutoDestroy=true)
 Plays a force feedback effect at the given location. 更多...
 
static UForceFeedbackComponent * SpawnForceFeedbackAttached (UForceFeedbackEffect *ForceFeedbackEffect, USceneComponent *AttachToComponent, FName AttachPointName=NAME_None, FVector Location=FVector(ForceInit), FRotator Rotation=FRotator::ZeroRotator, EAttachLocation::Type LocationType=EAttachLocation::KeepRelativeOffset, bool bStopWhenAttachedToDestroyed=false, bool bLooping=false, float IntensityMultiplier=1.f, float StartTime=0.f, class UForceFeedbackAttenuation *AttenuationSettings=nullptr, bool bAutoDestroy=true)
 Plays a force feedback effect attached to and following the specified component. 更多...
 
static UAudioComponent * SpawnSound2D (const UObject *WorldContextObject, USoundBase *Sound, float VolumeMultiplier=1.f, float PitchMultiplier=1.f, float StartTime=0.f, USoundConcurrency *ConcurrencySettings=nullptr, bool bPersistAcrossLevelTransition=false, bool bAutoDestroy=true)
 Spawns a sound with no attenuation, perfect for UI sounds. 更多...
 
static UAudioComponent * SpawnSoundAtLocation (const UObject *WorldContextObject, USoundBase *Sound, FVector Location, FRotator Rotation=FRotator::ZeroRotator, float VolumeMultiplier=1.f, float PitchMultiplier=1.f, float StartTime=0.f, class USoundAttenuation *AttenuationSettings=nullptr, USoundConcurrency *ConcurrencySettings=nullptr, bool bAutoDestroy=true)
 Spawns a sound at the given location. 更多...
 
static UAudioComponent * SpawnSoundAttached (USoundBase *Sound, USceneComponent *AttachToComponent, FName AttachPointName=NAME_None, FVector Location=FVector(ForceInit), FRotator Rotation=FRotator::ZeroRotator, EAttachLocation::Type LocationType=EAttachLocation::KeepRelativeOffset, bool bStopWhenAttachedToDestroyed=false, float VolumeMultiplier=1.f, float PitchMultiplier=1.f, float StartTime=0.f, USoundAttenuation *AttenuationSettings=nullptr, USoundConcurrency *ConcurrencySettings=nullptr, bool bAutoDestroy=true)
 Plays a sound attached to and following the specified component. 更多...
 
static 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. 更多...
 
static bool SuggestProjectileVelocity (const UObject *WorldContextObject, FVector &TossVelocity, FVector StartLocation, FVector EndLocation, float TossSpeed, bool bHighArc=false, float CollisionRadius=0.f, float OverrideGravityZ=0, ESuggestProjVelocityTraceOption::Type TraceOption=ESuggestProjVelocityTraceOption::TraceFullPath, const FCollisionResponseParams &ResponseParam=FCollisionResponseParams::DefaultResponseParam, const TArray< AActor * > &ActorsToIgnore=TArray< AActor * >(), bool bDrawDebug=false)
 Native version, has more options than the Blueprint version.
 
static bool SuggestProjectileVelocity_CustomArc (const UObject *WorldContextObject, FVector &OutLaunchVelocity, FVector StartPos, FVector EndPos, float OverrideGravityZ=0, float ArcParam=0.5f)
 Returns the launch velocity needed for a projectile at rest at StartPos to land on EndPos. 更多...
 

详细描述

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

成员函数说明

◆ ActivateReverbEffect()

static void UGameplayStatics::ActivateReverbEffect ( const UObject *  WorldContextObject,
class UReverbEffect *  ReverbEffect,
FName  TagName,
float  Priority = 0.f,
float  Volume = 0.5f,
float  FadeTime = 2.f 
)
static

Activates a Reverb Effect without the need for a volume

参数
ReverbEffectReverb Effect to use
TagNameTag to associate with Reverb Effect
PriorityPriority of the Reverb Effect
VolumeVolume level of Reverb Effect
FadeTimeTime before Reverb Effect is fully active

◆ AnnounceAccessibleString()

static void UGameplayStatics::AnnounceAccessibleString ( const FString &  AnnouncementString)
static

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

These announcements can be interrupted by system accessibiliity announcements or other accessibility announcement requests. This should be used judiciously as flooding a player with announcements can be overrwhelming and confusing. Try to make announcements concise and clear. NOTE: Currently only supported on Win10, Mac, iOS

◆ AreAnyListenersWithinRange()

static bool UGameplayStatics::AreAnyListenersWithinRange ( const UObject *  WorldContextObject,
const FVector &  Location,
float  MaximumRange 
)
static

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

参数
LocationThe location to potentially play a sound at
MaximumRangeThe maximum distance away from Location that a listener can be
注解
This will always return false if there is no audio device, or the audio device is disabled.

◆ AreSubtitlesEnabled()

static bool UGameplayStatics::AreSubtitlesEnabled ( )
static

Returns whether or not subtitles are currently enabled.

返回
true if subtitles are enabled.

◆ AsyncLoadGameFromSlot()

static void UGameplayStatics::AsyncLoadGameFromSlot ( const FString &  SlotName,
const int32  UserIndex,
FAsyncLoadGameFromSlotDelegate  LoadedDelegate 
)
static

Schedule an async load of a specific slot.

UAsyncActionHandleSaveGame::AsyncLoadGameFromSlot is the blueprint version of this. This will do the platform-specific read on a worker thread, the serialize and creation on the game thread, and then will call the passed in delegate The passed in delegate will be copied to a worker thread so make sure any payload is thread safe to copy by value

参数
SlotNameName of the save game slot to load from.
UserIndexFor some platforms, master user index to identify the user doing the loading.
LoadedDelegateDelegate that will be called on game thread when load succeeds or fails.

◆ AsyncSaveGameToSlot()

static void UGameplayStatics::AsyncSaveGameToSlot ( USaveGame *  SaveGameObject,
const FString &  SlotName,
const int32  UserIndex,
FAsyncSaveGameToSlotDelegate  SavedDelegate = FAsyncSaveGameToSlotDelegate() 
)
static

Schedule an async save to a specific slot.

UAsyncActionHandleSaveGame::AsyncSaveGameToSlot is the blueprint version of this. This will do the serialize on the game thread, the platform-specific write on a worker thread, then call the complete delegate on the game thread. The passed in delegate will be copied to a worker thread so make sure any payload is thread safe to copy by value.

参数
SaveGameObjectObject that contains data about the save game that we want to write out.
SlotNameName of the save game slot to load from.
UserIndexFor some platforms, master user index to identify the user doing the loading.
SavedDelegateDelegate that will be called on game thread when save succeeds or fails.

◆ Blueprint_PredictProjectilePath_Advanced()

static bool UGameplayStatics::Blueprint_PredictProjectilePath_Advanced ( const UObject *  WorldContextObject,
const FPredictProjectilePathParams &  PredictParams,
FPredictProjectilePathResult &  PredictResult 
)
static

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

Returns true if it hit something.

参数
PredictParamsInput params to the trace (start location, velocity, time to simulate, etc).
PredictResultOutput result of the trace (Hit result, array of location/velocity/times for each trace step, etc).
返回
True if hit something along the path (if tracing with collision).

◆ Blueprint_PredictProjectilePath_ByObjectType()

static bool UGameplayStatics::Blueprint_PredictProjectilePath_ByObjectType ( const UObject *  WorldContextObject,
FHitResult &  OutHit,
TArray< FVector > &  OutPathPositions,
FVector &  OutLastTraceDestination,
FVector  StartPos,
FVector  LaunchVelocity,
bool  bTracePath,
float  ProjectileRadius,
const TArray< TEnumAsByte< EObjectTypeQuery > > &  ObjectTypes,
bool  bTraceComplex,
const TArray< AActor * > &  ActorsToIgnore,
EDrawDebugTrace::Type  DrawDebugType,
float  DrawDebugTime,
float  SimFrequency = 15.f,
float  MaxSimTime = 2.f,
float  OverrideGravityZ = 0 
)
static

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

Returns a list of positions of the simulated arc and the destination reached by the simulation. Returns true if it hit something.

参数
OutPathPositionsPredicted projectile path. Ordered series of positions from StartPos to the end. Includes location at point of impact if it hit something.
OutHitPredicted hit result, if the projectile will hit something
OutLastTraceDestinationGoal position of the final trace it did. Will not be in the path if there is a hit.
StartPosFirst start trace location
LaunchVelocityVelocity the "virtual projectile" is launched at
bTracePathTrace along the entire path to look for blocking hits
ProjectileRadiusRadius of the virtual projectile to sweep against the environment
ObjectTypesObjectTypes to trace against, if bTracePath is true.
bTraceComplexUse TraceComplex (trace against triangles not primitives)
ActorsToIgnoreActors to exclude from the traces
DrawDebugTypeDebug type (one-frame, duration, persistent)
DrawDebugTimeDuration of debug lines (only relevant for DrawDebugType::Duration)
SimFrequencyDetermines size of each sub-step in the simulation (chopping up MaxSimTime)
MaxSimTimeMaximum simulation time for the virtual projectile.
OverrideGravityZOptional override of Gravity (if 0, uses WorldGravityZ)
返回
True if hit something along the path if tracing for collision.

◆ Blueprint_PredictProjectilePath_ByTraceChannel()

static bool UGameplayStatics::Blueprint_PredictProjectilePath_ByTraceChannel ( const UObject *  WorldContextObject,
FHitResult &  OutHit,
TArray< FVector > &  OutPathPositions,
FVector &  OutLastTraceDestination,
FVector  StartPos,
FVector  LaunchVelocity,
bool  bTracePath,
float  ProjectileRadius,
TEnumAsByte< ECollisionChannel >  TraceChannel,
bool  bTraceComplex,
const TArray< AActor * > &  ActorsToIgnore,
EDrawDebugTrace::Type  DrawDebugType,
float  DrawDebugTime,
float  SimFrequency = 15.f,
float  MaxSimTime = 2.f,
float  OverrideGravityZ = 0 
)
static

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

Returns a list of positions of the simulated arc and the destination reached by the simulation. Returns true if it hit something (if tracing with collision).

参数
OutPathPositionsPredicted projectile path. Ordered series of positions from StartPos to the end. Includes location at point of impact if it hit something.
OutHitPredicted hit result, if the projectile will hit something
OutLastTraceDestinationGoal position of the final trace it did. Will not be in the path if there is a hit.
StartPosFirst start trace location
LaunchVelocityVelocity the "virtual projectile" is launched at
bTracePathTrace along the entire path to look for blocking hits
ProjectileRadiusRadius of the virtual projectile to sweep against the environment
TraceChannelTraceChannel to trace against, if bTracePath is true.
bTraceComplexUse TraceComplex (trace against triangles not primitives)
ActorsToIgnoreActors to exclude from the traces
DrawDebugTypeDebug type (one-frame, duration, persistent)
DrawDebugTimeDuration of debug lines (only relevant for DrawDebugType::Duration)
SimFrequencyDetermines size of each sub-step in the simulation (chopping up MaxSimTime)
MaxSimTimeMaximum simulation time for the virtual projectile.
OverrideGravityZOptional override of Gravity (if 0, uses WorldGravityZ)
返回
True if hit something along the path (if tracing with collision).

◆ BlueprintSuggestProjectileVelocity()

static bool UGameplayStatics::BlueprintSuggestProjectileVelocity ( const UObject *  WorldContextObject,
FVector &  TossVelocity,
FVector  StartLocation,
FVector  EndLocation,
float  LaunchSpeed,
float  OverrideGravityZ,
ESuggestProjVelocityTraceOption::Type  TraceOption,
float  CollisionRadius,
bool  bFavorHighArc,
bool  bDrawDebug 
)
static

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

参数
TossVelocity(output) Result launch velocity.
StartLocationIntended launch location
EndLocationDesired landing location
LaunchSpeedDesired launch speed
OverrideGravityZOptional gravity override. 0 means "do not override".
TraceOptionControls whether or not to validate a clear path by tracing along the calculated arc
CollisionRadiusRadius of the projectile (assumed spherical), used when tracing
bFavorHighArcIf true and there are 2 valid solutions, will return the higher arc. If false, will favor the lower arc.
bDrawDebugWhen true, a debug arc is drawn (red for an invalid arc, green for a valid arc)
返回
Returns false if there is no valid solution or the valid solutions are blocked. Returns true otherwise.

◆ BreakHitResult()

static void UGameplayStatics::BreakHitResult ( const struct FHitResult &  Hit,
bool &  bBlockingHit,
bool &  bInitialOverlap,
float &  Time,
float &  Distance,
FVector &  Location,
FVector &  ImpactPoint,
FVector &  Normal,
FVector &  ImpactNormal,
class UPhysicalMaterial *&  PhysMat,
class AActor *&  HitActor,
class UPrimitiveComponent *&  HitComponent,
FName &  HitBoneName,
int32 &  HitItem,
int32 &  FaceIndex,
FVector &  TraceStart,
FVector &  TraceEnd 
)
static

Extracts data from a HitResult.

参数
HitThe source HitResult.
bBlockingHitTrue if there was a blocking hit, false otherwise.
bInitialOverlapTrue if the hit started in an initial overlap. In this case some other values should be interpreted differently. Time will be 0, ImpactPoint will equal Location, and normals will be equal and indicate a depenetration vector.
Time'Time' of impact along trace direction ranging from [0.0 to 1.0) if there is a hit, indicating time between start and end. Equals 1.0 if there is no hit.
DistanceThe distance from the TraceStart to the Location in world space. This value is 0 if there was an initial overlap (trace started inside another colliding object).
LocationLocation of the hit in world space. If this was a swept shape test, this is the location where we can place the shape in the world where it will not penetrate.
NormalNormal of the hit in world space, for the object that was swept (e.g. for a sphere trace this points towards the sphere's center). Equal to ImpactNormal for line tests.
ImpactPointLocation of the actual contact point of the trace shape with the surface of the hit object. Equal to Location in the case of an initial overlap.
ImpactNormalNormal of the hit in world space, for the object that was hit by the sweep.
PhysMatPhysical material that was hit. Must set bReturnPhysicalMaterial to true in the query params for this to be returned.
HitActorActor hit by the trace.
HitComponentPrimitiveComponent hit by the trace.
HitBoneNameName of the bone hit (valid only if we hit a skeletal mesh).
HitItemPrimitive-specific data recording which item in the primitive was hit
FaceIndexIf colliding with trimesh or landscape, index of face that was hit.

◆ ClearSoundMixClassOverride()

static void UGameplayStatics::ClearSoundMixClassOverride ( const UObject *  WorldContextObject,
class USoundMix *  InSoundMixModifier,
class USoundClass *  InSoundClass,
float  FadeOutTime = 1.0f 
)
static

Clears the override of the sound class adjuster in the given sound mix.

If the override did not exist in the sound mix, this will do nothing.

参数
InSoundMixModifierThe sound mix to modify.
InSoundClassThe sound class to override (or add) in the sound mix.
FadeOutTimeThe interpolation time to use to go from the current sound class adjuster override values to the non-override values.

◆ CreateSaveGameObject()

static USaveGame * UGameplayStatics::CreateSaveGameObject ( TSubclassOf< USaveGame >  SaveGameClass)
static

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

参数
SaveGameClassClass of SaveGame to create
返回
New SaveGame object to write data to

◆ CreateSound2D()

static UAudioComponent * UGameplayStatics::CreateSound2D ( const UObject *  WorldContextObject,
USoundBase *  Sound,
float  VolumeMultiplier = 1.f,
float  PitchMultiplier = 1.f,
float  StartTime = 0.f,
USoundConcurrency *  ConcurrencySettings = nullptr,
bool  bPersistAcrossLevelTransition = false,
bool  bAutoDestroy = true 
)
static

Creates a sound with no attenuation, perfect for UI sounds.

This does NOT play the sound

  • Not Replicated.
    参数
    Sound- Sound to create.
    VolumeMultiplier- Multiplied with the volume to make the sound louder or softer.
    PitchMultiplier- Multiplies the pitch.
    StartTime- How far in to the sound to begin playback at
    ConcurrencySettings- Override concurrency settings package to play sound with
    PersistAcrossLevelTransition- Whether the sound should continue to play when the map it was played in is unloaded
    bAutoDestroy- Whether the returned audio component will be automatically cleaned up when the sound finishes (by completing or stopping) or whether it can be reactivated
    返回
    An audio component to manipulate the created sound

◆ DeactivateReverbEffect()

static void UGameplayStatics::DeactivateReverbEffect ( const UObject *  WorldContextObject,
FName  TagName 
)
static

Deactivates a Reverb Effect not applied by a volume

参数
TagNameTag associated with Reverb Effect to remove

◆ DeleteGameInSlot()

static bool UGameplayStatics::DeleteGameInSlot ( const FString &  SlotName,
const int32  UserIndex 
)
static

Delete a save game in a particular slot.

参数
SlotNameName of save game slot to delete.
UserIndexFor some platforms, master user index to identify the user doing the deletion.
返回
True if a file was actually able to be deleted. use DoesSaveGameExist to distinguish between delete failures and failure due to file not existing.

◆ DeprojectScreenToWorld()

static bool UGameplayStatics::DeprojectScreenToWorld ( APlayerController const *  Player,
const FVector2D &  ScreenPosition,
FVector &  WorldPosition,
FVector &  WorldDirection 
)
static

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

参数
PlayerDeproject using this player's view.
ScreenPosition2D screen space to deproject.
WorldPosition(out) Corresponding 3D position in world space.
WorldDirection(out) World space direction vector away from the camera at the given 2d point.

◆ DoesSaveGameExist()

static bool UGameplayStatics::DoesSaveGameExist ( const FString &  SlotName,
const int32  UserIndex 
)
static

See if a save game exists with the specified name.

参数
SlotNameName of save game slot.
UserIndexFor some platforms, master user index to identify the user doing the saving.

◆ EnableLiveStreaming()

static void UGameplayStatics::EnableLiveStreaming ( bool  Enable)
static

Toggle live DVR streaming.

参数
EnableIf true enable streaming, otherwise disable.

◆ FindCollisionUV()

static bool UGameplayStatics::FindCollisionUV ( const struct FHitResult &  Hit,
int32  UVChannel,
FVector2D &  UV 
)
static

Try and find the UV for a collision impact.

Note this ONLY works if 'Support UV From Hit Results' is enabled in Physics Settings.

◆ GetAccurateRealTime()

static void UGameplayStatics::GetAccurateRealTime ( const UObject *  WorldContextObject,
int32 &  Seconds,
float &  PartialSeconds 
)
static

Returns time in seconds since the application was started.

Unlike the other time functions this is accurate to the exact time this function is called instead of set once per frame.

◆ GetClosestListenerLocation()

static bool UGameplayStatics::GetClosestListenerLocation ( const UObject *  WorldContextObject,
const FVector &  Location,
float  MaximumRange,
const bool  bAllowAttenuationOverride,
FVector &  ListenerPosition 
)
static

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

参数
LocationThe location from which we'd like to find the closest listener, in world space.
MaximumRangeThe maximum distance away from Location that a listener can be.
bAllowAttenuationOverrideTrue for the adjusted listener position (if attenuation override is set), false for the raw listener position (for panning)
ListenerPosition[Out] The position of the closest listener in world space, if found.
返回
true if we've successfully found a listener within MaximumRange of Location, otherwise false.
注解
This will always return false if there is no audio device, or the audio device is disabled.

◆ GetIntOption()

static int32 UGameplayStatics::GetIntOption ( const FString &  Options,
const FString &  Key,
int32  DefaultValue 
)
static

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

参数
OptionsThe string containing the options.
KeyThe key to find the value of in Options.
返回
The value associated with Key as an integer if Key found in Options string, otherwise DefaultValue.

◆ GetKeyValue()

static void UGameplayStatics::GetKeyValue ( const FString &  Pair,
FString &  Key,
FString &  Value 
)
static

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

参数
PairThe string containing a pair to split apart.
Key(out) Key portion of Pair. If no = in string will be the same as Pair.
Value(out) Value portion of Pair. If no = in string will be empty.

◆ GetPlatformName()

static FString UGameplayStatics::GetPlatformName ( )
static

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

(Platform names include Windows, Mac, IOS, Android, PS4, XboxOne, Linux)

◆ GetSurfaceType()

static EPhysicalSurface UGameplayStatics::GetSurfaceType ( const struct FHitResult &  Hit)
static

Returns the EPhysicalSurface type of the given Hit.

To edit surface type for your project, use ProjectSettings/Physics/PhysicalSurface section

◆ GetViewProjectionMatrix()

static void UGameplayStatics::GetViewProjectionMatrix ( FMinimalViewInfo  DesiredView,
FMatrix &  ViewMatrix,
FMatrix &  ProjectionMatrix,
FMatrix &  ViewProjectionMatrix 
)
static

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

参数
DesiredViewFMinimalViewInfo struct for a camera.
ViewMatrix(out) Corresponding View Matrix
ProjectionMatrix(out) Corresponding Projection Matrix
ViewProjectionMatrix(out) Corresponding View x Projection Matrix

◆ GrassOverlappingSphereCount()

static int32 UGameplayStatics::GrassOverlappingSphereCount ( const UObject *  WorldContextObject,
const UStaticMesh *  StaticMesh,
FVector  CenterPosition,
float  Radius 
)
static

Counts how many grass foliage instances overlap a given sphere.

参数
MeshThe static mesh we are interested in counting.
CenterPositionThe center position of the sphere.
RadiusThe radius of the sphere.
返回
Number of foliage instances with their mesh set to Mesh that overlap the sphere.

◆ HasLaunchOption()

static bool UGameplayStatics::HasLaunchOption ( const FString &  OptionToCheck)
static

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

-demobuild)

返回
True if the launch option was specified on the commandline, false otherwise

◆ HasOption()

static bool UGameplayStatics::HasOption ( FString  Options,
const FString &  InKey 
)
static

Returns whether a key exists in an options string.

参数
OptionsThe string containing the options.
KeyThe key to determine if it exists in Options.
返回
Whether Key was found in Options.

◆ LoadDataFromSlot()

static bool UGameplayStatics::LoadDataFromSlot ( TArray< uint8 > &  OutSaveData,
const FString &  SlotName,
const int32  UserIndex 
)
static

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

参数
OutSaveDataData buffer to load into
SlotNameName of save game slot to save to.
UserIndexFor some platforms, master user index to identify the user doing the saving.
返回
Whether valid save data was found and loaded.

◆ LoadGameFromMemory()

static USaveGame * UGameplayStatics::LoadGameFromMemory ( const TArray< uint8 > &  InSaveData)
static

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

参数
InSaveDataThe array containing the serialized USaveGame data to load
返回
Object containing loaded game state (nullptr if load fails)

◆ LoadGameFromSlot()

static USaveGame * UGameplayStatics::LoadGameFromSlot ( const FString &  SlotName,
const int32  UserIndex 
)
static

Load the contents from a given slot.

参数
SlotNameName of the save game slot to load from.
UserIndexFor some platforms, master user index to identify the user doing the loading.
返回
Object containing loaded game state (nullptr if load fails)

◆ MakeHitResult()

static FHitResult UGameplayStatics::MakeHitResult ( bool  bBlockingHit,
bool  bInitialOverlap,
float  Time,
float  Distance,
FVector  Location,
FVector  ImpactPoint,
FVector  Normal,
FVector  ImpactNormal,
class UPhysicalMaterial *  PhysMat,
class AActor *  HitActor,
class UPrimitiveComponent *  HitComponent,
FName  HitBoneName,
int32  HitItem,
int32  FaceIndex,
FVector  TraceStart,
FVector  TraceEnd 
)
static

Create a HitResult struct

参数
HitThe source HitResult.
bBlockingHitTrue if there was a blocking hit, false otherwise.
bInitialOverlapTrue if the hit started in an initial overlap. In this case some other values should be interpreted differently. Time will be 0, ImpactPoint will equal Location, and normals will be equal and indicate a depenetration vector.
Time'Time' of impact along trace direction ranging from [0.0 to 1.0) if there is a hit, indicating time between start and end. Equals 1.0 if there is no hit.
DistanceThe distance from the TraceStart to the Location in world space. This value is 0 if there was an initial overlap (trace started inside another colliding object).
LocationLocation of the hit in world space. If this was a swept shape test, this is the location where we can place the shape in the world where it will not penetrate.
NormalNormal of the hit in world space, for the object that was swept (e.g. for a sphere trace this points towards the sphere's center). Equal to ImpactNormal for line tests.
ImpactPointLocation of the actual contact point of the trace shape with the surface of the hit object. Equal to Location in the case of an initial overlap.
ImpactNormalNormal of the hit in world space, for the object that was hit by the sweep.
PhysMatPhysical material that was hit. Must set bReturnPhysicalMaterial to true in the query params for this to be returned.
HitActorActor hit by the trace.
HitComponentPrimitiveComponent hit by the trace.
HitBoneNameName of the bone hit (valid only if we hit a skeletal mesh).
HitItemPrimitive-specific data recording which item in the primitive was hit
FaceIndexIf colliding with trimesh or landscape, index of face that was hit.

◆ ParseOption()

static FString UGameplayStatics::ParseOption ( FString  Options,
const FString &  Key 
)
static

Find an option in the options string and return it.

参数
OptionsThe string containing the options.
KeyThe key to find the value of in Options.
返回
The value associated with Key if Key found in Options string.

◆ PlayDialogue2D()

static void UGameplayStatics::PlayDialogue2D ( const UObject *  WorldContextObject,
UDialogueWave *  Dialogue,
const struct FDialogueContext &  Context,
float  VolumeMultiplier = 1.f,
float  PitchMultiplier = 1.f,
float  StartTime = 0.f 
)
static

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

  • Fire and Forget.
  • Not Replicated.
    参数
    Dialogue- dialogue to play
    Context- context the dialogue is to play in
    VolumeMultiplier- Multiplied with the volume to make the sound louder or softer.
    PitchMultiplier- Multiplies the pitch.
    StartTime- How far in to the dialogue to begin playback at

◆ PlayDialogueAtLocation()

static void UGameplayStatics::PlayDialogueAtLocation ( const UObject *  WorldContextObject,
class UDialogueWave *  Dialogue,
const FDialogueContext &  Context,
FVector  Location,
FRotator  Rotation,
float  VolumeMultiplier = 1.f,
float  PitchMultiplier = 1.f,
float  StartTime = 0.f,
USoundAttenuation *  AttenuationSettings = nullptr 
)
static

Plays a dialogue at the given location.

This is a fire and forget sound and does not travel with any actor. Replication is also not handled at this point.

参数
Dialogue- dialogue to play
Context- context the dialogue is to play in
Location- World position to play dialogue at
Rotation- World rotation to play dialogue at
VolumeMultiplier- Volume multiplier
PitchMultiplier- Pitch multiplier
StartTime- How far in to the dialogue to begin playback at
AttenuationSettings- Override attenuation settings package to play sound with

◆ PlaySound2D()

static void UGameplayStatics::PlaySound2D ( const UObject *  WorldContextObject,
USoundBase *  Sound,
float  VolumeMultiplier = 1.f,
float  PitchMultiplier = 1.f,
float  StartTime = 0.f,
USoundConcurrency *  ConcurrencySettings = nullptr,
AActor *  OwningActor = nullptr,
bool  bIsUISound = true 
)
static

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

  • Fire and Forget.
  • Not Replicated.
    参数
    Sound- Sound to play.
    VolumeMultiplier- Multiplied with the volume to make the sound louder or softer.
    PitchMultiplier- Multiplies the pitch.
    ConcurrencySettings- Override concurrency settings package to play sound with
    StartTime- How far in to the sound to begin playback at
    ConcurrencySettings- Override concurrency settings package to play sound with
    OwningActor- The actor to use as the "owner" for concurrency settings purposes. Allows PlaySound calls to do a concurrency limit per owner.
    bIsUISound- True if sound is UI related, else false

◆ PlaySoundAtLocation()

static void UGameplayStatics::PlaySoundAtLocation ( const UObject *  WorldContextObject,
USoundBase *  Sound,
FVector  Location,
FRotator  Rotation,
float  VolumeMultiplier = 1.f,
float  PitchMultiplier = 1.f,
float  StartTime = 0.f,
class USoundAttenuation *  AttenuationSettings = nullptr,
USoundConcurrency *  ConcurrencySettings = nullptr,
AActor *  OwningActor = nullptr 
)
static

Plays a sound at the given location.

This is a fire and forget sound and does not travel with any actor. Replication is also not handled at this point.

参数
Sound- sound to play
Location- World position to play sound at
Rotation- World rotation to play sound at
VolumeMultiplier- Volume multiplier
PitchMultiplier- PitchMultiplier
StartTime- How far in to the sound to begin playback at
AttenuationSettings- Override attenuation settings package to play sound with
ConcurrencySettings- Override concurrency settings package to play sound with
OwningActor- The actor to use as the "owner" for concurrency settings purposes. Allows PlaySound calls to do a concurrency limit per owner.

◆ PredictProjectilePath()

static bool UGameplayStatics::PredictProjectilePath ( const UObject *  WorldContextObject,
const FPredictProjectilePathParams &  PredictParams,
FPredictProjectilePathResult &  PredictResult 
)
static

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

Returns true if it hit something.

参数
PredictParamsInput params to the trace (start location, velocity, time to simulate, etc).
PredictResultOutput result of the trace (Hit result, array of location/velocity/times for each trace step, etc).
返回
True if hit something along the path (if tracing with collision).

◆ ProjectWorldToScreen()

static bool UGameplayStatics::ProjectWorldToScreen ( APlayerController const *  Player,
const FVector &  WorldPosition,
FVector2D &  ScreenPosition,
bool  bPlayerViewportRelative = false 
)
static

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

参数
PlayerProject using this player's view.
WorldPositionWorld position to project.
ScreenPosition(out) Corresponding 2D position in screen space
bPlayerViewportRelativeShould this be relative to the player viewport subregion (useful when using player attached widgets in split screen)

◆ SaveDataToSlot()

static bool UGameplayStatics::SaveDataToSlot ( const TArray< uint8 > &  InSaveData,
const FString &  SlotName,
const int32  UserIndex 
)
static

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

参数
InSaveDataData to save
SlotNameName of save game slot to save to.
UserIndexFor some platforms, master user index to identify the user doing the saving.
返回
Whether we successfully saved this information

◆ SaveGameToMemory()

static bool UGameplayStatics::SaveGameToMemory ( USaveGame *  SaveGameObject,
TArray< uint8 > &  OutSaveData 
)
static

Serialize our USaveGame object into a given array of bytes

注解
This will write out all non-transient properties, the SaveGame property flag is not checked
参数
SaveGameObjectObject that contains data about the save game that we want to write out
OutSaveDataByte array that is written into
返回
Whether we successfully wrote data

◆ SaveGameToSlot()

static bool UGameplayStatics::SaveGameToSlot ( USaveGame *  SaveGameObject,
const FString &  SlotName,
const int32  UserIndex 
)
static

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

注解
This will write out all non-transient properties, the SaveGame property flag is not checked
参数
SaveGameObjectObject that contains data about the save game that we want to write out
SlotNameName of save game slot to save to.
UserIndexFor some platforms, master user index to identify the user doing the saving.
返回
Whether we successfully saved this information

◆ SetGlobalListenerFocusParameters()

static void UGameplayStatics::SetGlobalListenerFocusParameters ( const UObject *  WorldContextObject,
float  FocusAzimuthScale = 1.0f,
float  NonFocusAzimuthScale = 1.0f,
float  FocusDistanceScale = 1.0f,
float  NonFocusDistanceScale = 1.0f,
float  FocusVolumeScale = 1.0f,
float  NonFocusVolumeScale = 1.0f,
float  FocusPriorityScale = 1.0f,
float  NonFocusPriorityScale = 1.0f 
)
static

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

  • Fire and Forget.
  • Not Replicated.
    参数
    FocusAzimuthScale- An angle scale value used to scale the azimuth angle that defines where sounds are in-focus.
    NonFocusAzimuthScale-An angle scale value used to scale the azimuth angle that defines where sounds are out-of-focus.
    FocusDistanceScale- A distance scale value to use for sounds which are in-focus. Values < 1.0 will reduce perceived distance to sounds, values > 1.0 will increase perceived distance to in-focus sounds.
    NonFocusDistanceScale- A distance scale value to use for sounds which are out-of-focus. Values < 1.0 will reduce perceived distance to sounds, values > 1.0 will increase perceived distance to in-focus sounds.
    FocusVolumeScale-A volume attenuation value to use for sounds which are in-focus.
    NonFocusVolumeScale-A volume attenuation value to use for sounds which are out-of-focus.
    FocusPriorityScale- A priority scale value (> 0.0) to use for sounds which are in-focus. Values < 1.0 will reduce the priority of in-focus sounds, values > 1.0 will increase the priority of in-focus sounds.
    NonFocusPriorityScale- A priority scale value (> 0.0) to use for sounds which are out-of-focus. Values < 1.0 will reduce the priority of sounds out-of-focus sounds, values > 1.0 will increase the priority of out-of-focus sounds.

◆ SetGlobalPitchModulation()

static void UGameplayStatics::SetGlobalPitchModulation ( const UObject *  WorldContextObject,
float  PitchModulation,
float  TimeSec 
)
static

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

  • Fire and Forget.
  • Not Replicated.
    参数
    PitchModulation- A pitch modulation value to globally set.
    TimeSec- A time value to linearly interpolate the global modulation pitch over from it's current value.

◆ SetMaxAudioChannelsScaled()

static void UGameplayStatics::SetMaxAudioChannelsScaled ( const UObject *  WorldContextObject,
float  MaxChannelCountScale 
)
static

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

E.g. if you want to temporarily reduce voice count by 50%, use 0.50. Later, you can return to the original max voice count by using 1.0.

◆ SetSoundClassDistanceScale()

static void UGameplayStatics::SetSoundClassDistanceScale ( const UObject *  WorldContextObject,
USoundClass *  SoundClass,
float  DistanceAttenuationScale,
float  TimeSec = 0.0f 
)
static

Sets attenuation distance scale value on the sound class over the given amount of time from it's current attenuation distance override value (1.0f it not overridden).

Attenuation scale allows scaling the attenuation distance used for computing distance attenuation.

  • Fire and Forget.
  • Not Replicated.
    参数
    SoundClass- Sound class to to use to set the attenuation distance scale on.
    DistanceAttenuationScale- A distance attenuation scale value.
    TimeSec- A time value to linearly interpolate from the current distance attenuation scale value to the new value.

◆ SetSoundMixClassOverride()

static void UGameplayStatics::SetSoundMixClassOverride ( const UObject *  WorldContextObject,
class USoundMix *  InSoundMixModifier,
class USoundClass *  InSoundClass,
float  Volume = 1.0f,
float  Pitch = 1.0f,
float  FadeInTime = 1.0f,
bool  bApplyToChildren = true 
)
static

Overrides the sound class adjuster in the given sound mix.

If the sound class does not exist in the input sound mix, the sound class adjustment will be added to the sound mix.

参数
InSoundMixModifierThe sound mix to modify.
InSoundClassThe sound class to override (or add) in the sound mix.
VolumeThe volume scale to set the sound class adjuster to.
PitchThe pitch scale to set the sound class adjuster to.
FadeInTimeThe interpolation time to use to go from the current sound class adjuster values to the new values.
bApplyToChildrenWhether or not to apply this override to the sound class' children or to just the specified sound class.

◆ SetSubtitlesEnabled()

static void UGameplayStatics::SetSubtitlesEnabled ( bool  bEnabled)
static

Will set subtitles to be enabled or disabled.

参数
bEnabledwill enable subtitle drawing if true, disable if false.

◆ SpawnDecalAtLocation()

static UDecalComponent * UGameplayStatics::SpawnDecalAtLocation ( const UObject *  WorldContextObject,
class UMaterialInterface *  DecalMaterial,
FVector  DecalSize,
FVector  Location,
FRotator  Rotation = FRotator(-90, 0, 0),
float  LifeSpan = 0 
)
static

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

Does not replicate.

参数
DecalMaterial- decal's material
DecalSize- size of decal
Location- location to place the decal in world space
Rotation- rotation to place the decal in world space
LifeSpan- destroy decal component after time runs out (0 = infinite)

◆ SpawnDecalAttached()

static UDecalComponent * UGameplayStatics::SpawnDecalAttached ( class UMaterialInterface *  DecalMaterial,
FVector  DecalSize,
class USceneComponent *  AttachToComponent,
FName  AttachPointName = NAME_None,
FVector  Location = FVector(ForceInit),
FRotator  Rotation = FRotator::ZeroRotator,
EAttachLocation::Type  LocationType = EAttachLocation::KeepRelativeOffset,
float  LifeSpan = 0 
)
static

Spawns a decal attached to and following the specified component.

Does not replicate.

参数
DecalMaterial- decal's material
DecalSize- size of decal
AttachComponent- Component to attach to.
AttachPointName- Optional named point within the AttachComponent to spawn the emitter at
Location- Depending on the value of Location Type this is either a relative offset from the attach component/point or an absolute world position that will be translated to a relative offset
Rotation- Depending on the value of LocationType this is either a relative offset from the attach component/point or an absolute world rotation that will be translated to a realative offset
LocationType- Specifies whether Location is a relative offset or an absolute world position
LifeSpan- destroy decal component after time runs out (0 = infinite)

◆ SpawnDialogue2D()

static UAudioComponent * UGameplayStatics::SpawnDialogue2D ( const UObject *  WorldContextObject,
UDialogueWave *  Dialogue,
const struct FDialogueContext &  Context,
float  VolumeMultiplier = 1.f,
float  PitchMultiplier = 1.f,
float  StartTime = 0.f,
bool  bAutoDestroy = true 
)
static

Spawns a dialogue with no attenuation, perfect for UI.

  • Not Replicated.
    参数
    Dialogue- dialogue to play
    Context- context the dialogue is to play in
    VolumeMultiplier- Multiplied with the volume to make the sound louder or softer.
    PitchMultiplier- Multiplies the pitch.
    StartTime- How far in to the dialogue to begin playback at
    bAutoDestroy- Whether the returned audio component will be automatically cleaned up when the sound finishes (by completing or stopping) or whether it can be reactivated
    返回
    An audio component to manipulate the spawned sound

◆ SpawnDialogueAtLocation()

static UAudioComponent * UGameplayStatics::SpawnDialogueAtLocation ( const UObject *  WorldContextObject,
UDialogueWave *  Dialogue,
const struct FDialogueContext &  Context,
FVector  Location,
FRotator  Rotation = FRotator::ZeroRotator,
float  VolumeMultiplier = 1.f,
float  PitchMultiplier = 1.f,
float  StartTime = 0.f,
USoundAttenuation *  AttenuationSettings = nullptr,
bool  bAutoDestroy = true 
)
static

Plays a dialogue at the given location.

This is a fire and forget sound and does not travel with any actor. Replication is also not handled at this point.

参数
Dialogue- dialogue to play
Context- context the dialogue is to play in
Location- World position to play dialogue at
Rotation- World rotation to play dialogue at
VolumeMultiplier- Volume multiplier
PitchMultiplier- PitchMultiplier
StartTime- How far in to the dialogue to begin playback at
AttenuationSettings- Override attenuation settings package to play sound with
bAutoDestroy- Whether the returned audio component will be automatically cleaned up when the sound finishes (by completing or stopping) or whether it can be reactivated
返回
Audio Component to manipulate the playing dialogue with

◆ SpawnDialogueAttached()

static UAudioComponent * UGameplayStatics::SpawnDialogueAttached ( UDialogueWave *  Dialogue,
const FDialogueContext &  Context,
USceneComponent *  AttachToComponent,
FName  AttachPointName = NAME_None,
FVector  Location = FVector(ForceInit),
FRotator  Rotation = FRotator::ZeroRotator,
EAttachLocation::Type  LocationType = EAttachLocation::KeepRelativeOffset,
bool  bStopWhenAttachedToDestroyed = false,
float  VolumeMultiplier = 1.f,
float  PitchMultiplier = 1.f,
float  StartTime = 0.f,
USoundAttenuation *  AttenuationSettings = nullptr,
bool  bAutoDestroy = true 
)
static

Spawns a dialogue attached to and following the specified component.

This is a fire and forget sound. Replication is also not handled at this point.

参数
Dialogue- dialogue to play
Context- context the dialogue is to play in
AttachComponent- Component to attach to.
AttachPointName- Optional named point within the AttachComponent to play the sound at
Location- Depending on the value of Location Type this is either a relative offset from the attach component/point or an absolute world position that will be translated to a relative offset
Rotation- Depending on the value of Location Type this is either a relative offset from the attach component/point or an absolute world rotation that will be translated to a relative offset
LocationType- Specifies whether Location is a relative offset or an absolute world position
bStopWhenAttachedToDestroyed- Specifies whether the sound should stop playing when the owner of the attach to component is destroyed.
VolumeMultiplier- Volume multiplier
PitchMultiplier- PitchMultiplier
StartTime- How far in to the dialogue to begin playback at
AttenuationSettings- Override attenuation settings package to play sound with
bAutoDestroy- Whether the returned audio component will be automatically cleaned up when the sound finishes (by completing or stopping) or whether it can be reactivated
返回
Audio Component to manipulate the playing dialogue with

◆ SpawnEmitterAttached()

static UParticleSystemComponent * UGameplayStatics::SpawnEmitterAttached ( class UParticleSystem *  EmitterTemplate,
class USceneComponent *  AttachToComponent,
FName  AttachPointName = NAME_None,
FVector  Location = FVector(ForceInit),
FRotator  Rotation = FRotator::ZeroRotator,
FVector  Scale = FVector(1.f),
EAttachLocation::Type  LocationType = EAttachLocation::KeepRelativeOffset,
bool  bAutoDestroy = true,
EPSCPoolMethod  PoolingMethod = EPSCPoolMethod::None,
bool  bAutoActivate = true 
)
static

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

The system will go away when the effect is complete. Does not replicate.

参数
EmitterTemplate- particle system to create
AttachComponent- Component to attach to.
AttachPointName- Optional named point within the AttachComponent to spawn the emitter at
Location- Depending on the value of LocationType this is either a relative offset from the attach component/point or an absolute world location that will be translated to a relative offset (if LocationType is KeepWorldPosition).
Rotation- Depending on the value of LocationType this is either a relative offset from the attach component/point or an absolute world rotation that will be translated to a relative offset (if LocationType is KeepWorldPosition).
Scale- Depending on the value of LocationType this is either a relative scale from the attach component or an absolute world scale that will be translated to a relative scale (if LocationType is KeepWorldPosition).
LocationType- Specifies whether Location is a relative offset or an absolute world position
bAutoDestroy- Whether the component will automatically be destroyed when the particle system completes playing or whether it can be reactivated
PoolingMethod- Method used for pooling this component. Defaults to none.
bAutoActivate- Whether the component will be automatically activated on creation.

◆ SpawnForceFeedbackAtLocation()

static UForceFeedbackComponent * UGameplayStatics::SpawnForceFeedbackAtLocation ( const UObject *  WorldContextObject,
UForceFeedbackEffect *  ForceFeedbackEffect,
FVector  Location,
FRotator  Rotation = FRotator::ZeroRotator,
bool  bLooping = false,
float  IntensityMultiplier = 1.f,
float  StartTime = 0.f,
UForceFeedbackAttenuation *  AttenuationSettings = nullptr,
bool  bAutoDestroy = true 
)
static

Plays a force feedback effect at the given location.

This is a fire and forget effect and does not travel with any actor. Replication is also not handled at this point.

参数
ForceFeedbackEffect- effect to play
Location- World position to center the effect at
Rotation- World rotation to center the effect at
IntensityMultiplier- Intensity multiplier
StartTime- How far in to the feedback effect to begin playback at
AttenuationSettings- Override attenuation settings package to play effect with
bAutoDestroy- Whether the returned force feedback component will be automatically cleaned up when the feedback patern finishes (by completing or stopping) or whether it can be reactivated
返回
Force Feedback Component to manipulate the playing feedback effect with

◆ SpawnForceFeedbackAttached()

static UForceFeedbackComponent * UGameplayStatics::SpawnForceFeedbackAttached ( UForceFeedbackEffect *  ForceFeedbackEffect,
USceneComponent *  AttachToComponent,
FName  AttachPointName = NAME_None,
FVector  Location = FVector(ForceInit),
FRotator  Rotation = FRotator::ZeroRotator,
EAttachLocation::Type  LocationType = EAttachLocation::KeepRelativeOffset,
bool  bStopWhenAttachedToDestroyed = false,
bool  bLooping = false,
float  IntensityMultiplier = 1.f,
float  StartTime = 0.f,
class UForceFeedbackAttenuation *  AttenuationSettings = nullptr,
bool  bAutoDestroy = true 
)
static

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

This is a fire and forget effect. Replication is also not handled at this point.

参数
ForceFeedbackEffect- effect to play
AttachComponent- Component to attach to.
AttachPointName- Optional named point within the AttachComponent to attach to
Location- Depending on the value of Location Type this is either a relative offset from the attach component/point or an absolute world position that will be translated to a relative offset
Rotation- Depending on the value of Location Type this is either a relative offset from the attach component/point or an absolute world rotation that will be translated to a relative offset
LocationType- Specifies whether Location is a relative offset or an absolute world position
bStopWhenAttachedToDestroyed- Specifies whether the feedback effect should stop playing when the owner of the attach to component is destroyed.
IntensityMultiplier- Intensity multiplier
StartTime- How far in to the feedback effect to begin playback at
AttenuationSettings- Override attenuation settings package to play effect with
bAutoDestroy- Whether the returned force feedback component will be automatically cleaned up when the feedback patern finishes (by completing or stopping) or whether it can be reactivated
返回
Force Feedback Component to manipulate the playing feedback effect with

◆ SpawnSound2D()

static UAudioComponent * UGameplayStatics::SpawnSound2D ( const UObject *  WorldContextObject,
USoundBase *  Sound,
float  VolumeMultiplier = 1.f,
float  PitchMultiplier = 1.f,
float  StartTime = 0.f,
USoundConcurrency *  ConcurrencySettings = nullptr,
bool  bPersistAcrossLevelTransition = false,
bool  bAutoDestroy = true 
)
static

Spawns a sound with no attenuation, perfect for UI sounds.

  • Not Replicated.
    参数
    Sound- Sound to play.
    VolumeMultiplier- Multiplied with the volume to make the sound louder or softer.
    PitchMultiplier- Multiplies the pitch.
    StartTime- How far in to the sound to begin playback at
    ConcurrencySettings- Override concurrency settings package to play sound with
    PersistAcrossLevelTransition- Whether the sound should continue to play when the map it was played in is unloaded
    bAutoDestroy- Whether the returned audio component will be automatically cleaned up when the sound finishes (by completing or stopping) or whether it can be reactivated
    返回
    An audio component to manipulate the spawned sound

◆ SpawnSoundAtLocation()

static UAudioComponent * UGameplayStatics::SpawnSoundAtLocation ( const UObject *  WorldContextObject,
USoundBase *  Sound,
FVector  Location,
FRotator  Rotation = FRotator::ZeroRotator,
float  VolumeMultiplier = 1.f,
float  PitchMultiplier = 1.f,
float  StartTime = 0.f,
class USoundAttenuation *  AttenuationSettings = nullptr,
USoundConcurrency *  ConcurrencySettings = nullptr,
bool  bAutoDestroy = true 
)
static

Spawns a sound at the given location.

This does not travel with any actor. Replication is also not handled at this point.

参数
Sound- sound to play
Location- World position to play sound at
Rotation- World rotation to play sound at
VolumeMultiplier- Volume multiplier
PitchMultiplier- PitchMultiplier
StartTime- How far in to the sound to begin playback at
AttenuationSettings- Override attenuation settings package to play sound with
ConcurrencySettings- Override concurrency settings package to play sound with
bAutoDestroy- Whether the returned audio component will be automatically cleaned up when the sound finishes (by completing or stopping) or whether it can be reactivated
返回
An audio component to manipulate the spawned sound

◆ SpawnSoundAttached()

static UAudioComponent * UGameplayStatics::SpawnSoundAttached ( USoundBase *  Sound,
USceneComponent *  AttachToComponent,
FName  AttachPointName = NAME_None,
FVector  Location = FVector(ForceInit),
FRotator  Rotation = FRotator::ZeroRotator,
EAttachLocation::Type  LocationType = EAttachLocation::KeepRelativeOffset,
bool  bStopWhenAttachedToDestroyed = false,
float  VolumeMultiplier = 1.f,
float  PitchMultiplier = 1.f,
float  StartTime = 0.f,
USoundAttenuation *  AttenuationSettings = nullptr,
USoundConcurrency *  ConcurrencySettings = nullptr,
bool  bAutoDestroy = true 
)
static

Plays a sound attached to and following the specified component.

This is a fire and forget sound. Replication is also not handled at this point.

参数
Sound- sound to play
AttachComponent- Component to attach to.
AttachPointName- Optional named point within the AttachComponent to play the sound at
Location- Depending on the value of Location Type this is either a relative offset from the attach component/point or an absolute world position that will be translated to a relative offset
Rotation- Depending on the value of Location Type this is either a relative offset from the attach component/point or an absolute world rotation that will be translated to a relative offset
LocationType- Specifies whether Location is a relative offset or an absolute world position
bStopWhenAttachedToDestroyed- Specifies whether the sound should stop playing when the owner of the attach to component is destroyed.
VolumeMultiplier- Volume multiplier
PitchMultiplier- PitchMultiplier
StartTime- How far in to the sound to begin playback at
AttenuationSettings- Override attenuation settings package to play sound with
ConcurrencySettings- Override concurrency settings package to play sound with
bAutoDestroy- Whether the returned audio component will be automatically cleaned up when the sound finishes (by completing or stopping) or whether it can be reactivated
返回
An audio component to manipulate the spawned sound

◆ StripSaveGameHeader()

static FMemoryReader UGameplayStatics::StripSaveGameHeader ( const TArray< uint8 > &  SaveData)
static

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.

参数
SaveDataA byte array, presumably produced by one of the SaveGame functions here.
返回
A memory reader, wrapping SaveData, offset to the point past the header data.

◆ SuggestProjectileVelocity_CustomArc()

static bool UGameplayStatics::SuggestProjectileVelocity_CustomArc ( const UObject *  WorldContextObject,
FVector &  OutLaunchVelocity,
FVector  StartPos,
FVector  EndPos,
float  OverrideGravityZ = 0,
float  ArcParam = 0.5f 
)
static

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

Assumes a medium arc (e.g. 45 deg on level ground). Projectile velocity is variable and unconstrained. Does no tracing.

参数
OutLaunchVelocityReturns the launch velocity required to reach the EndPos
StartPosStart position of the simulation
EndPosDesired end location for the simulation
OverrideGravityZOptional override of WorldGravityZ
ArcParamChange height of arc between 0.0-1.0 where 0.5 is the default medium arc, 0 is up, and 1 is directly toward EndPos.

该类的文档由以下文件生成: