- Home /
Why my sound it's not attaching to my Flashlight
I have a Script attached to a simple spot light that is my flashlight, so I tried to add to my existant Flashlight Script a Sound Script, So when I press "f" the light is on and so the sound, and viceversa. Unity finds no errors, but still my sound (a click to know I turn the flashlight on) is not playing when I use "f". I have added an audio source to the flashlight, the sound on the script and the audio source, I have clicked on Play on Awake to turn that off... Any ideas someone??:) My Flashlight Script (Now with audio on it, but not working:/):
var linkedLight : Light;
function Update () { if(Input.GetKeyDown("f")){ linkedLight.enabled = !linkedLight.enabled; } }
var shootSound:AudioClip;
 if(Input.GetKeyDown("f")){
     audio.PlayOneShot(shootSound);
 }  
}
Yes, in both, The script one, attached to the flashlight and the audio source slot too...
Answer by fafase · Aug 24, 2012 at 11:41 PM
 var linkedLight : Light;
 var shootSound:AudioClip;
 
 function Update () { 
   if(Input.GetKeyDown("f")){ 
     linkedLight.enabled = !linkedLight.enabled; 
     audio.PlayOneShot(shootSound);
   }
 }
 
second part is not in the update
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                