I have looked around and cannot seem to find anyone with a similar problem, and I have tried many different ways to get my audio to play. I have a sphere that destroys when it is hit with another sphere using onCollisionEnter. That part works fine. Where i’m having issues is getting my audio clip to play when this happens. I have made one of the spheres an audio source, currently do not have the clip stored in the clip attribute of the audio source. I can get the clip to play by calling audio.PlayOneShot() in the Start() function, but not in my onCollisionEnter. Here is my C# code.
void OnCollisionEnter(Collision collision) {
if(collision.gameObject.tag == "Dart") {
audio.PlayOneShot(Pop, 1f);
Destroy(collision.gameObject);
Destroy(gameObject);
}
Any help is greatly appreciated,
Corey