The pitch of the audio source.
#pragma strict @RequireComponent(AudioSource) public var startingPitch: int = 4; public var timeToDecrease: int = 5; var audioSource: AudioSource; function Start() { audioSource = GetComponent.<AudioSource>(); audioSource.pitch = startingPitch; } function Update() { if (audioSource.pitch > 0) audioSource.pitch -= Time.deltaTime * startingPitch / timeToDecrease; }
using UnityEngine; using System.Collections;
[RequireComponent(typeof(AudioSource))] public class ExampleClass : MonoBehaviour { public int startingPitch = 4; public int timeToDecrease = 5; AudioSource audioSource;
void Start() { audioSource = GetComponent<AudioSource>(); audioSource.pitch = startingPitch; }
void Update() { if (audioSource.pitch > 0) audioSource.pitch -= Time.deltaTime * startingPitch / timeToDecrease; } }
Did you find this page useful? Please give it a rating: