Legacy Documentation: Version 4.6(go to latest)
Language: English
  • C#
  • JS
  • Boo

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.

	// Decreases the pitch in the given seconds

var startingPitch = 4; var timeToDecrease = 5; @script RequireComponent(AudioSource) function Start() { audio.pitch = startingPitch; }

function Update() { if(audio.pitch > 0) audio.pitch -= ((Time.deltaTime * startingPitch) / timeToDecrease); }