Adjust audio playback rate with Time.timeScale

Hey,

I currently have a scene set up that utilizes Time.timeScale. It works perfectly for achieving the slow motion effect I was after. The only thing is that It does not effect the audio playback speed, so it feels kinda awkward. Is there some thing similar to Time.timeScale, but for audio playback speed? Or is there a way to sync the audio with the video so that it matches the time scale?

Thanks in advance!

Indeed there is! audio.pitch it is. A value of 1 is normal, .5 is twice slower. Negative values read the audioclip in reverse. Won’t affect PlayOneShot, of course…

What I think you could do with the Audio is using one single function to play audio, and in that function make audio.pitch = Time.timeScale… as you’ll be using that function to play all the audio then problem solved

function PlaySound (soundName, soundDelay)
{
	if(!audio.isPlaying && Time.time>soundRate)
	{
        audio.pitch = Time.timeScale;
		soundRate = Time.time + soundDelay;
		audio.clip = soundName;
		audio.Play();
		yield WaitForSeconds(audio.clip.length);
	}

}