- Home /
Audio Problem
Hey everyone!
I'm having an issue with audio. I have an object that I want to destroy and to play an explosion audio when it happens but it won't play because the object will be destroyed when it is used and there for, stopped. Knowing that I have multiple copies of this object coming in on screen all the time how can I get something to play the sound every time one of these are destroyed? I've been searching for ages and I still am so I was just wandering if any of you had any handy ideas.
Thanks everyone for your ideas!
Answer by tanoshimi · Feb 20, 2015 at 04:52 PM
Simple approach is not to destroy the enemy at first but just disable its renderer, making it invisible while the sound effect plays. Then destroy it after the sound has ended ( i.e. Invoke("DestroyMe", explosionClip.Length);
That's not a bad idea that. I'll give it a go ;)
Answer by AlucardJay · Feb 20, 2015 at 07:48 PM
http://docs.unity3d.com/ScriptReference/AudioSource.PlayClipAtPoint.html
http://docs.unity3d.com/ScriptReference/AudioSource.PlayOneShot.html
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
PlayClipAtPoint Qualify with Type Name 2 Answers
How to adjust game sound from UI Slider? 1 Answer
Audio/c#/unity Can i control the duration by time ? 1 Answer