- Home /
Problem with enabling and playing audios
Hello,
the function below is supposed to simulate a "dialogue", where based on a pressed key it plays an audio clip (with playing an opening sentences at the beginning). However, when it gets to the lines after WaitForSeconds(2), I don't see the objects which were supposed to spawn and nothing happens after I press v,b,n or m. I have no idea about what might be causing the problem and I would appreciate any help. I am able to provide more details, of course.
And, btw, after that WaitForSeconds(2) line, when I pause the game, it seems like the objects are activated, but I don't see them. And, these game objects are all children of a bigger object, if that is to any help.
function OnTriggerEnter () {
audio.PlayOneShot(IHaveCustomer);
yield WaitForSeconds(9);
animation.Play();
audio.PlayOneShot(HowCanHelp);
yield WaitForSeconds (2);
WhatIsThis.SetActive(true);
WhoAreU.SetActive(true);
HowCanIGetO.SetActive(true);
if (Input.GetKeyDown(KeyCode.V)) {
audio.PlayOneShot(WhatIsThisPlace);
}
if (Input.GetKeyDown(KeyCode.B)) {
audio.PlayOneShot(WhoAreYou);
}
if (Input.GetKeyDown(KeyCode.N)) {
audio.PlayOneShot(HowCanGetOut);
yield WaitForSeconds(10);
WhatIsThis.SetActive(false);
WhoAreU.SetActive(false);
HowCanIGetO.SetActive(false);
WhereArePar.SetActive(true);
if (Input.GetKeyDown(KeyCode.M)) {
audio.PlayOneShot(WhereAreParts);
yield WaitForSeconds (14);
WhereArePar.SetActive(false);
EndConversation.SetActive(true);
if (Input.GetKeyDown(KeyCode.X));
monster.SetActive(false);
audio.PlayOneShot(Scary);
}
}
}
Your answer
Follow this Question
Related Questions
Audio Clip trouble 2 Answers
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
Synch clips with BPM 2 Answers
Music will not change when an event triggers it 3 Answers
How to play several audio cllips one after another. 3 Answers