- Home /
How to create multiple choice question with audio clip
HI, Am very new to Unity Javascript
I am creating a children's App,
I have a button called Media Quiz - when this buttons is clicked. i want it to show a multiple choice question,the question will be having animal sound(the child will listen to the clip and select the correct answer) . I have attach the audio.
This is what i have so far and i have no clue on how to do it, Please help
function Animal_Sound()
{
var Cat : AudioClip;
var Dog : AudioClip;
var Baboon : AudioClip;
var Lion : AudioClip;
var Pig : AudioClip;
var PlayAnimalSound : int;
var Animalsound : AudioClip[] = new AudioClip[5];
for(var i = 1 : i >=5; int++ )
{
if(PlayAnimalSound ==1)
{
Cat.audio.Play();
}
if(PlayAnimalSound ==2)
{
Dog.audio.Play();
}
}
}
function ChangeMusic()
{
audio.AudioClip = Random.Range(1,5);
audio.Play();
}
sorry for my english
I cannot visualize what you want here. Or more specifically, I can visualize several things that meet your description. A visual would be helpful along with a description of how it should work. You should explore the GUI class for your buttons.
Note there are a number of compiler issues with your code. Some simple, some more complex. The one that stands out is that an AudioClip does not have an 'audio'. Assu$$anonymous$$g you have an AudioSource attached to the same game object as the above script, you can do:
audio.PlayOneShot(Cat);
Also it would be better if you had an array of audio clips rather than a list of individual clips.
Your answer
Follow this Question
Related Questions
Update () cant be a coroutine 2 Answers
Input key Conversion Query? 0 Answers
Adding a solid mesh 1 Answer
How can i insert a package? 1 Answer
Changing alpha on specific vertexes? 1 Answer