- Home /
 
AudioClip[] bug
 function EngineSound()
 {
     audio.pitch = RRwheel.rpm/TopRPM + 0.5;
     for(var i = 0;i < Sounds.Length; i++)
     {
         audio.clip = Sounds[i];
         
         i = Gear;
     }
 } 
 
               i tried to make realistic car sounds by changing the audioClip on each gear. There's no errors but the unity editor freezes. the script is above the "Sounds" variable is just a AudioClip[];.
For future posts, please format your code. I did it for you this time.
Answer by mwbranna · Oct 22, 2014 at 07:28 PM
 i = Gear;
 
               This line will always replace whatever was in "i" with Gear. You are stuck in an infinite loop (since "i" won't continually be incremented) if Gear < Sounds.Length.
Your answer
 
             Follow this Question
Related Questions
Question about audio (AudioSource). My ingame sound doesn't sound like the original audio file? 3 Answers
Make the audio manager select from an array of sounds 1 Answer
Play Audio in sequence from children objects 3 Answers
How to manage player and enemies shooting sounds at the same time? 1 Answer
Need help to play a random explosion sound from an array. 1 Answer