Legacy Documentation: Version 5.1
LanguageEnglish
  • C#
  • JS

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

AudioSource.pitch

Switch to Manual
public var pitch: float;

Description

The pitch of the audio source.

#pragma strict
@RequireComponent(AudioSource)
public var startingPitch: int = 4;
public var timeToDecrease: int = 5;
var audio: AudioSource;
function Start() {
	audio = GetComponent.<AudioSource>();
	audio.pitch = startingPitch;
}
function Update() {
	if (audio.pitch > 0)
		audio.pitch -= Time.deltaTime * startingPitch / timeToDecrease;
}