LEAP Documentation 40220
Documentation for the LEAP project
SplineSoundComponent.h
Go to the documentation of this file.
1// Copyright Blue Isle Studios Inc 2018. All Rights Reserved.
2
3#pragma once
4
5#include "CoreMinimal.h"
6#include "Components/ActorComponent.h"
7#include "SplineSoundComponent.generated.h"
8
9UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
10class PROJECTX_API USplineSoundComponent : public UActorComponent
11{
12 GENERATED_BODY()
13
14public:
15 /* Looping sound to play near and inside the volume */
16 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = Sound)
17 class USoundBase* Sound;
18 /* Attenuation settings */
19 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = Sound)
20 class USoundAttenuation* AttenuationSettings;
21 /* How often does the volume check for player proximity (per second) before activating itself? */
22 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = Sound)
23 float InactiveTickInterval = 1.0f;
24 /* How often does the volume update the sound position (per second) when the player is near? */
25 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = Sound)
26 float ActiveTickInterval = 0.1f;
27 /* How fast (in seconds) does the sound fade in as the player draws within attenuation range? */
28 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = Sound)
29 float ActivationFadeInTime = 0.5f;
30 /* Visualize the position of the spatial sound volume and the moving sound within it */
31 UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = Sound)
32 bool bShowDebug = false;
33
34 USplineSoundComponent();
35
36 virtual void BeginPlay() override;
37 virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
38
39private:
40 UPROPERTY()
41 class UAudioComponent* AudioComponent;
42 UPROPERTY()
43 class USplineComponent* SplineComponent;
44
45 float FalloffSqured = 0.0f;
46
47 FVector GetSoundLocation(const AActor* const Listener) const;
48
49 void Optimize(const FVector& AudioComponentLocation, const AActor* const Listener);
50};