Hi, I am trying to create a button that, when you press it, you get a beep and then the same beep when you release your touch AND THEN one second after the second beep, there will be a randomly chosen sound from an array of 50 sounds that could be played. I studied a similar problem from Random Audio Clip Help - Unity Answers and put all my sounds in the array. I get two errors. One is: Assets/MyScripts/MaleSoberSound.js(31,18): BCE0044: expecting (, found ‘PlayRandom’.
and the other is: Assets/MyScripts/MaleSoberSound.js(31,31): UCE0001: ‘;’ expected. Insert a semicolon at the end.
I don’t know where to search to find what I’m doing wrong in my script. I would greatly appreciate help on this javascript I created.
Thanks so much in advance!!!
Tom
#pragma strict
var sounds: AudioClip[];
function Start ()
{
}
function Update ()
{
}
function OnMouseDown ()
{
audio.Play();
//Application.OpenURL ("http://www.google.com");
Debug.Log ("I touched the Microphone!");
}
function OnMouseUp ()
{
audio.Play();
yield WaitForSeconds (1);
function PlayRandom () //call this function to play a random sound.
{
if (audio.isPlaying) return; // don't play a new sound while the last sound hasn't finished.
audio.clip = sounds[Random.Range(0,sounds.length)];
audio.Play();
}
Debug.Log ("I released the Mic button.");
}