- Home /
Question by
cole1497 · Oct 23, 2011 at 03:52 AM ·
javascriptclickdoorsound effects
Sound effect on right click
I'm trying to make my script play an audio sound when I right click, to open the door.
Here is a part of my code (javascript):
if(enter == true){
if(Input.GetButtonDown("Fire2")){
open = !open;
}
}
Comment
Answer by aldonaletto · Oct 23, 2011 at 03:56 AM
You must add an AudioSource to the door, define the sound to be played in the Clip property and play the sound with audio.Play():
if(enter == true){ if(Input.GetButtonDown("Fire2")){ open = !open; if (open) audio.Play(); // play audio if door is opening } }