Problem playing a sound

I have this code here:

public AudioClip pop;

if(collide.gameObject.tag == "bullet")
{

    audio.PlayOneShot(pop);
    Destroy (collide.gameObject);
    Destroy (gameObject);
}

I want the sound to play when my bullet collides with the enemy, but so far I get nothing, my enemies all have Audio Sources and the audioClip is added to them in the project view. I have other sounds working, just having trouble with this one, anyone know why that might be?

1 Answer

1

Did you try not to destroy gameObject immediately? audio.PlayOneShot can’t play if the gameObject doesn’t exist.