- Home /
 
Boolean and audio is not working right
(the first part is to help you guys understand my script more better the question is near the bottom)ok i have a script that chooses one music out of 3 music (song 1 - song 3) for th background music which works good and when the player picks up the rocket power up the background music changes to the power up music or song 4 which works great to but when the power up effects is gone the song 4 is suppose to stop and the song that was playing before should continue playing but it doesn't work and i don't know how to make the other song continue playing do i need another audio source or something plz help
 var song2 : AudioClip; 
 var song3 : AudioClip;
 var song4 : AudioClip;
 var kill : boolean = true; 
 var count : float = 0;
 
 
 function Start () {
 
 
 }
 
 function Update () {  
 
 if(choose){
 var x = Random.Range(1,4); 
 choose = (false); }
 
 
  
   if(x == 1) {
  audio.clip = song1;
  audio.Play();}
   
   
   if(x == 2){  
 audio.clip = song2; 
 audio.Play();} 
   
  if(x == 3){ 
 audio.clip = song3; 
 audio.Play();}
 
 if(lifeanddeath.rocket == (true)){ 
 audio.Pause();  
 audio.clip = song4; 
 audio.Play();} 
 
 
 } 
 
 
 }
 
 
 
 
     
  
  
 
 
 
 
 
 
 function Awake () { 
 
 
         DontDestroyOnLoad (transform.gameObject); 
 
     
     
     }  
 
              ok i used more audio sourses and it works thx @xortrox
Answer by xortrox · Apr 21, 2014 at 04:00 AM
Using multiple audio sources would probably be the easiest. You could also check out audio.PlayOneShot for this purpose.
Your answer