- Home /
Question by
gonzalitosk8 · Jun 11, 2014 at 05:30 PM ·
audiowaitforsecondssolution
help whit WaitForSecond use.
can someone give me a solution or example? look at the example of WaitForSecond but get it right!
I have 3 AudioSource:
L M H
these are executed automatically with engine revs .. I want to do, is to push a button (next gear) 3 audios stop for the number of seconds to put on a "public float"
eg if (input.GetbuttonDown ("next")) { LSource.Stop (); MSource.Stop (); HSource.Stop (); (for x amount of time) }
the script is written in c #!
Comment
Answer by Jessespike · Jun 11, 2014 at 05:40 PM
Read this: http://docs.unity3d.com/Manual/Coroutines.html
void Update()
{
if (input.GetbuttonDown ("next"))
{
StartCoroutine( MyCoroutine() );
}
}
IEnumerator MyCoroutine()
{
// Do stuff before wait, ie Stop sounds
yield return new WaitForSeconds(3f);
// Do whatever after X seconds, ie Continue playing sounds
}
Your answer
Follow this Question
Related Questions
play audio for few seconds on key hit 1 Answer
How to prevent more mouse clicks that trigger sound. 3 Answers
IEnumerator issues 3 Answers
someone is there? 1 Answer
Script not working anymore 1 Answer