- Home /
Audio Destroy Help!
I am making a simple Horror game, in Unity, and what would be worse than a horror game without sound effects?,
function OnTriggerEnter(other: Collider){
if (!audio.isPlaying){
audio.Play(); Destroy.audio(); } }
I do not know if this is the right script to use to destroy audio, (as I am a newbie) if you do know the right script!, please reply! thanks. :)
Answer by gregzo · Jul 27, 2013 at 11:27 AM
The proper way to destroy the AudioSource would be
Destroy ( audio );
But in your script, that would destroy the AudioSource component before it has a chance to play. Why do you want to destroy the audio component anyway?
Well, I got the script off of a YouTube video, i'm trying to get a door to open, and the sound goes, but when you go through it again, (when it's open) the sound still plays, that is what i'm having trouble with :|
$$anonymous$$ake sure the "One Shot" tick is active on your AudioSource component in the inspector.
Is this feature in the Unity Pro?, cause I cannot find it in my Audio Component.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Can anyone help me invert this simple script? 2 Answers
Stuck on this! Please help me out. 1 Answer
Help with Simple Footsteps? 2 Answers
Wait for sound is played 2 Answers