Definition
SetSoundVolume(string soundObjectName, float volume)
Description
This function sets the volume of ambient or 3D sound soundObjectName to volume.
Parameters
soundObjectName
Specifies the ambient or 3D sound name. You can also use the name “this” for this parameter. In this case, “this” string refers to the name of the sound to which this script is attached.
volume
Specifies the volume of 3D or ambient sound soundObjectName to be set. This value must be in the range [0.0,1.0].
Example 1
function Init() SetSoundVolume("sound1", 0.1) end function Update() end
We set the volume of sound “sound1” to 0.1.
Example 2
--Name of script is SetSoundVolume2.lua function Init() SetSoundVolume("this", 0.2) end function Update() end
Assume that the above script named SetSoundVolume2.lua is attached to a sound object named “sound1”. In this case, string “this” in the SetSoundVolume function will be equal to “sound1”. In our example, the function SetSoundVolume sets the volume of current sound, which is “sound1”, to 0.2.
SetSoundVolume