For the life of me I cannot figure this out.
I am trying to get a sound clip to play at a random range of pitch and loop it continuously but such that it only plays again once it is done playing.
The program runs but it does not play the sound at all.
C# Script
using UnityEngine;
using System.Collections;
[RequireComponent(typeof(AudioSource))]
public class RandomThunder : MonoBehaviour {
public AudioClip clip;
IEnumerator Do()
{
audio.pitch = Random.Range(0.5f, 1.0f);
audio.PlayOneShot(clip);
yield return new WaitForSeconds(audio.clip.length);
}
// Use this for initialization
void Start ()
{
Do ();
}
// Update is called once per frame
void Update ()
{
}
}
Any help would be greatly appreciated.