SetSoundPitch

Definition

SetSoundPitch(string soundObjectName, float pitch)

Description

This function sets the pitch of ambient or 3D sound soundObjectName to pitch.

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.

pitch
pitch of 3D or ambient sound soundObjectName. This value must be greater than 0.0.

Example 1

function Init()
    SetSoundPitch("sound1", 1.5)
end

function Update()

end
This script sets the pitch of sound “sound1” to 1.5.

Example 2

--Name of script is SetSoundPitch2.lua

function Init()
    SetSoundPitch("this", 0.5)
end

function Update()

end
Assume that the above script named SetSoundPitch2.lua is attached to a sound object named “sound1”. In this case, string “this”  in the SetSoundPitch function will be equal to “sound1”. In our example, the function SetSoundPitch sets the pitch of current sound, which is “sound1”, to 0.5.
adminSetSoundPitch