One Shot Sound After Countdown JS
Hello
Is there a way I can have a One Shot Audio sample played after a certain amount of time, like 3 seconds in JavaScript? I've looked everywhere and can't seem to find what I'm looking for!
Thanks
Answer by lienadnellum · Nov 06, 2015 at 05:58 PM
Easy,keep in mind this is a very simple way of doing it Make a object, add component(audio source), on the component audio source un tick play on awake, drag your mp3(sound file) onto audio clip , then attach this script to the object " var SoundToPlayWhenGameStarts : AudioClip; var CountDownTime : float = 3;
function Start () {
yield WaitForSeconds(CountDownTime);
GetComponent.().PlayOneShot(SoundToPlayWhenGameStarts);
} " then drag your mp3(sound file) in unity onto the script variable(SoundToPlayWhenGameStarts), this is a very simple way, there many other ways. Hope this helped :)
Your answer
Follow this Question
Related Questions
Audio Endless Loop c# 1 Answer
Executing Actions Through PlayerPrefs 1 Answer
Destroy Object on Collision (with di sound) 0 Answers
Second AudioClip won't play 0 Answers
How can I make my audio work for both headphones and computer/laptop speakers? 0 Answers