Description
The Distance
property of the SoundEvent
class specifies the maximum distance, in units, from which the sound can be heard. This property is crucial for determining how sound attenuates over distance, allowing for more realistic audio experiences in a 3D environment.
Usage
To use the Distance
property, you can set it to a float
value representing the maximum audible distance for the sound. This property is part of the DistanceAttenuation
toggle group, meaning it is only relevant if distance attenuation is enabled for the sound event.
Example
// Example of setting the Distance property for a SoundEvent
SoundEvent mySoundEvent = new SoundEvent();
mySoundEvent.Distance = 100.0f; // The sound can be heard up to 100 units away
// Check if the sound should fade out over distance
if (mySoundEvent.DistanceAttenuation)
{
// Adjust the distance as needed
mySoundEvent.Distance = 150.0f;
}