GetSoundReferenceDistance

Definition

double GetSoundReferenceDistance(string 3DSoundObjectName)

Description

This function returns the reference distance of 3D sound 3DSoundObjectName.

Parameters

3DSoundObjectName
Specifies the 3D sound name. You can also use the name “this” for this parameter. In this case, “this” string refers to the name of the 3D sound to which this script is attached.

Return Value

Reference distance of 3D sound.

Example 1

ref_distance = 0.0

function Init()
    ref_distance = GetSoundReferenceDistance("sound1")

    message = string.format("\nSound reference distance is > %.2f", ref_distance)
    PrintConsole(message)
end

function Update()

end
First, we get the reference distance of 3D sound “sound1”. Then we display it in the console using the PrintConsole function.

Example 2

--Name of script is GetSoundReferenceDistance2.lua

ref_distance = 0.0

function Init()
    ref_distance = GetSoundReferenceDistance("this")

    message = string.format("\nSound reference distance is > %.2f", ref_distance)
    PrintConsole(message)
end

function Update()

end
Assume that the above script named GetSoundReferenceDistance2.lua is attached to a 3D sound object named “sound1”. In this case, string “this”  in the GetSoundReferenceDistance function will be equal to “sound1”. In our example, the function GetSoundReferenceDistance returns the reference distance of current 3D sound, which is “sound1”.
adminGetSoundReferenceDistance