Description
The Occlusion
property of the Sandbox.Audio.Mixer
class determines the extent to which sounds are occluded. This property is a float
value ranging from 0 to 1, where 0 means no occlusion and 1 means full occlusion. Occlusion affects how sounds are perceived when there are obstacles between the sound source and the listener, simulating the effect of sound being blocked or absorbed by objects in the environment.
Usage
To adjust the occlusion level of a sound mixer, set the Occlusion
property to a value between 0 and 1. This can be useful for creating realistic audio environments where sounds are affected by physical barriers.
Example
// Create a new audio mixer
Mixer audioMixer = new Mixer();
// Set the occlusion level to 0.5 (partial occlusion)
audioMixer.Occlusion = 0.5f;
// Retrieve the current occlusion level
float currentOcclusion = audioMixer.Occlusion;
// Output the current occlusion level
// Note: Avoid using Console.WriteLine in Sandbox
// Instead, use appropriate logging or debugging tools
// Debug.Log($"Current Occlusion: {currentOcclusion}");