5#include "CoreMinimal.h"
6#include "Components/ActorComponent.h"
7#include "SpatialSoundComponent.generated.h"
9UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
10class PROJECTX_API USpatialSoundComponent :
public UActorComponent
16 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = Sound)
17 class USoundBase* Sound;
19 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = Sound)
20 class USoundAttenuation* AttenuationSettings;
22 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = Sound)
23 float InactiveTickInterval = 1.0f;
25 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = Sound)
26 float ActiveTickInterval = 0.1f;
28 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = Sound)
29 float ActivationFadeInTime = 0.5f;
31 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = Sound)
34 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = Sound)
35 bool bIsDynamic = false;
37 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = Sound)
38 bool bShowDebug = false;
40 USpatialSoundComponent();
43 void RecalculateBox(const
bool bForce = false);
45 virtual
void BeginPlay() override;
46 virtual
void OnWorldOriginChanged(UWorld* World, FIntVector SizeX, FIntVector SizeY);
47 virtual
void TickComponent(
float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
51 class UAudioComponent* AudioComponent;
53 class UBoxComponent* BoxComponent;
55 float FalloffSqured = 0.0f;
59 FVector GetSoundLocation(const AActor* const Listener) const;
60 FVector GetNearestPointInPerimeter(const FVector& Point) const;
62 void Optimize(const FVector& AudioComponentLocation, const AActor* const Listener);