- Home /
Question by
AusAndrew19 · Jul 14, 2012 at 12:04 PM ·
audiosound
How to play Audio Once if enemy has enterd a trigger
Hi Guys. trying to make my zombie scream if he enters my trigger. This is the script i have came up with
var target : Collider;
private var triggered : boolean = false;
function OnTriggerEnter(collision : Collider)
{
if (collision !=target)
{
return;
}
triggered = true;
audio.Play();
}
How do i tell it what audio to play. My sound is called "ZombieScream"
also my zombie is taged Enemy if thats any help.
Comment
Best Answer
Answer by AlucardJay · Jul 14, 2012 at 01:43 PM
You want to use audio.PlayOneShot(clip : AudioClip);
http://docs.unity3d.com/Documentation/ScriptReference/AudioSource.PlayOneShot.html
Actually, this is the same as the answer I gave for your question : http://answers.unity3d.com/questions/278058/how-to-add-a-sound-to-this-script.html
Hellooo? thoughts, comments, feedback? You have only ever accepted one answer for all your questions : http://answers.unity3d.com/users/26838/ausandrew.html