Legacy Documentation: Version 5.0
Language: English
  • 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 = 4;
public var timeToDecrease = 5;
var audio;
function Start() {
	audio = GetComponent.<AudioSource>();
	audio.pitch = startingPitch;
}
function Update() {
	if (audio.pitch > 0)
		audio.pitch -= Time.deltaTime * startingPitch / timeToDecrease;
}