Search Unity

Audio Disable audio after clicking on trigger

Discussion in 'Audio & Video' started by ilonamarja, May 17, 2018.

  1. ilonamarja

    ilonamarja

    Joined:
    May 17, 2018
    Posts:
    9
    Hello,
    I am a newbie in C# , currently making a student project and wondering how can I disable audio after I've clicked on the trigger? In my scene I have a double doors. I can't open the doors without clicking on a key first. After picking up the key I click the door, it opens and plays "door open" -sound. If I (mistakenly) click the door second time, it plays the sound again (I don't mean looping). So how can I disable the audio after the door is opened? I've tried almost everything in my code and created a "already opened" boolean and a mute -audioclip but nothing seems to work. Here is my code now:

    the code.jpg

    Thanks!