- Home /
play sound after destroy the enemy by tag
i'm trying to play sound after completely destroy all enemies in the game to tell the player you have won by voice, so I tried code but it is not. so, I need other code that help me to achieve my purpose.
Answer by James_BadAlchemy · Oct 28, 2018 at 07:40 AM
Attach and AudioSource component to a gameobject. Add your sound clip the that AudioSource. Then when you want to play that sound, You can create a reference to that GameObject and use the AudioSource.Play(); Method.
I tried but it is not work look to my code void Update() { if (GameObject.FindWithTag("box") == null && GameObject.FindWithTag("BOX") == null && GameObject.FindWithTag("Cube") == null) {
timer -= Time.deltaTime;
if (timer <= 0)
{
Application.LoadLevel("T1EB");
}
}
} I want to add it here after destroy all the enemies play the sound then move to other scene I tried but not work I don't know .please help me .