- Home /
Question by
SpeedySpikes · Jan 03, 2011 at 10:55 PM ·
javascriptrandommusic
Random Music Track on Load
I'm porting a game to PC, Mac and iOS, and it contains a scene that plays one of three music tracks. Is there a way I can use a script to chose a random track, preferably in JavaScript?
Comment
Best Answer
Answer by Justin Warner · Jan 04, 2011 at 12:23 AM
Make an array of sounds, and use the random number generator to pick a number, and then that'll select one of the tracks, and you just play that. =).
As in i = Random.Range(0,3) -- http://unity3d.com/support/documentation/ScriptReference/Random.Range.html
Your answer
Follow this Question
Related Questions
Sound playing at random. (JS) 2 Answers
Instantiating a random dropped consumable item from many cloned objects 1 Answer
Adding GUI to this 1 Answer
Spawn random amount of gameobjects 2 Answers