- Home /
How to Have a Random Interval in an Array in between Sounds being Played?
Hey guys,
Basically, what I want to do is have an array with some sounds, which I have and it works fine. What I am trying to achieve is: I want a fixed, or even better a random interval between the sounds that are played.
So for example:
Sound A just finished playing.
Sound B will play next but only after say, 2 minutes.
Or, even better. Sound B will play after a random interval set between 2 to 5 minutes.
My array for the sounds is set up and works fine, I just need help with the interval part of the code.
Any ideas on how to do this?
Thanks in advance.
Answer by sfc.itzhak · Jul 15, 2013 at 06:57 AM
take a look at this http://docs.unity3d.com/Documentation/ScriptReference/Random.Range.html
just yield the random range
function Do () { print("Do now");
yield WaitForSeconds (Random.Range(120, 300));
print("Do 2-5 min later later");
}
if you need it in c# let me know
sfc
Your answer
Follow this Question
Related Questions
Sound Timing 1 Answer
Breathing sound effect using timers 1 Answer
slow a lerp ? array/static problem 1 Answer
How to Control the Animation using Slider ? 3 Answers
3d Audio Not Updating Listener Position When Time.timeScale set to 0 0 Answers