Space Plunder
Loading...
Searching...
No Matches
UProximityChatBPLib Class Reference

#include <ProximityChatBPLib.h>

Inheritance diagram for UProximityChatBPLib:

Static Public Member Functions

static float CalculateVoiceAttenuation (const FVector &SpeakerLocation, const FVector &ListenerLocation, float MaxDistance, float VolumeAtMaxDistance)
 

Member Function Documentation

◆ CalculateVoiceAttenuation()

float UProximityChatBPLib::CalculateVoiceAttenuation ( const FVector & SpeakerLocation,
const FVector & ListenerLocation,
float MaxDistance,
float VolumeAtMaxDistance )
static
8{
9 //- Calculate the distance between the speaker and the listener //
10 float Distance = FVector::Distance(SpeakerLocation, ListenerLocation);
11 //- Check if the listener is farther than the maximum distance //
12 if(Distance > MaxDistance)
13 {
14 //- The listener is too far away, no volume //
15 return 0.0f;
16 }
17 //- Calculate the attenuation factor based on the distance and the maximum distance //
18 const float AttenuationFactor = 1.0f - (Distance / MaxDistance);
19
20 //- Calculate the volume of the voice chat based on the attenuation factor and the volume at the maximum distance //
21 const float VoiceVolume = FMath::Lerp(VolumeAtMaxDistance, 1.0f, AttenuationFactor);
22 return VoiceVolume;
23
24
25}

The documentation for this class was generated from the following files: