I’m trying to have an audio file play when it’s destroyed but its not working.
Here is my code.
I have the audioclip set up here.
public AudioClip deathSound;
And here is the code that has the audio file in.
switch(other.tag)
{
case "EnemyProjectile":
audio.PlayOneShot(deathSound);
Instantiate(Explosion, transform.position, Quaternion.identity);
Destroy(other.gameObject);
GameManager.PlayerDies();
Destroy(gameObject);
break;
Would it be better to have a separate gameobject that handles all the sounds then?
– jadaithyou could try and destroy when on the completion of the sound playing. you should be able to tell when the clip is playing. once it completes then destroy your objects. then you don't need to have a separate object for sound.
– amaceika