float DistanceAttenuation { get; set; }

robot_2Generated
code_blocksInput

Description

The DistanceAttenuation property of the Sandbox.Audio.Mixer class controls how the volume of sounds decreases as they move further away from the listener. This property is a float value ranging from 0 to 1, where 0 means no attenuation (sounds do not get quieter with distance) and 1 means full attenuation (sounds get significantly quieter as they move away).

Usage

To use the DistanceAttenuation property, you can set it to a value between 0 and 1 depending on how much you want the sound to attenuate with distance. This can be useful for creating realistic audio environments where sounds naturally decrease in volume as they move away from the listener.

Example

// Example of setting the DistanceAttenuation property
Sandbox.Audio.Mixer audioMixer = new Sandbox.Audio.Mixer();
audioMixer.DistanceAttenuation = 0.5f; // Set to half attenuation