Definition
double GetSoundMaxDistance(string 3DSoundObjectName)
Description
This function returns the maximum 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
Maximum distance of 3D sound.
Example 1
max_distance = 0.0 function Init() max_distance = GetSoundMaxDistance("sound1") message = string.format("\nSound max distance is > %.2f", max_distance) PrintConsole(message) end function Update() end
First, we get the maximum distance of 3D sound “sound1”. Then we display it in the console using the PrintConsole function.
Example 2
--Name of script is GetSoundMaxDistance2.lua max_distance = 0.0 function Init() max_distance = GetSoundMaxDistance("this") message = string.format("\nSound max distance is > %.2f", max_distance) PrintConsole(message) end function Update() end
Assume that the above script named GetSoundMaxDistance2.lua is attached to a 3D sound object named “sound1”. In this case, string “this” in the GetSoundMaxDistance function will be equal to “sound1”. In our example, the function GetSoundMaxDistance returns the maximum distance of current 3D sound, which is “sound1”.
GetSoundMaxDistance