Description
The Distance
property of the SoundHandle
class specifies the maximum distance in units from which the sound can be heard. This property is useful for controlling how far the sound will propagate in the game world, allowing for more realistic audio effects based on the listener's proximity to the sound source.
Usage
To use the Distance
property, you can get or set its value on an instance of SoundHandle
. Setting this property will determine how far the sound can be heard from its source.
Example
// Create a new sound handle
SoundHandle sound = new SoundHandle();
// Set the distance the sound can be heard from
sound.Distance = 100.0f;
// Get the current distance value
float currentDistance = sound.Distance;
// Output the current distance
// Note: Avoid using Console.WriteLine in Sandbox
// Instead, use in-game debugging tools or UI elements
// Debug.Log($"Current sound distance: {currentDistance}");