SetSoundMaxDistance(string 3DSoundObjectName, float maxDistance)
This function sets the maximum distance of 3D sound 3DSoundObjectName to maxDistance.
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.
Specifies the maximum distance of 3D sound 3DSoundObjectName to be set. This value must be greater than or equal to 0.0.
function Init() SetSoundMaxDistance("sound1", 1.7) end function Update() end
This script sets the maximum distance of 3D sound “sound1” to 1.7.
--Name of script is SetSoundMaxDistance2.lua function Init() SetSoundMaxDistance("this", 2.5) end function Update() end
Assume that the above script named SetSoundMaxDistance2.lua is attached to a 3D sound object named “sound1”. In this case, string “this” in the SetSoundMaxDistance function will be equal to “sound1”. In our example, the function SetSoundMaxDistance sets the maximum distance of current 3D sound, which is “sound1”, to 2.5.SetSoundMaxDistance