#My Audio isn't playing when bullet is breaking. Top-down 2D

1 messages · Page 1 of 1 (latest)

crimson acorn
#

https://pastebin.com/4w9hep1E

I am trying to make a sound play when the bullet in my game breaks. It is used here:
() void BreakBullet(){ GameObject effect = Instantiate(hitEffect, transform.position, Quaternion.identity); AudioSource.PlayClipAtPoint(bulletDestroy, transform.position); Destroy(effect, 5f); Destroy(gameObject); } ()

I am using AudioSource.PlayClipAtPoint to create an audio source so there is one audiosource playing even when bullet gets destroyed. Yet the sound never plays in-game, what's up with that?

jolly talon
#

Is the audio source on this object

crimson acorn
jolly talon
#

You're destroying the bullet

#

Along with the audio source

crimson acorn
#

AudioSource.PlayClipAtPoint creates a new audiosource with the clip until it finishes playing

jolly talon
#

You can solve this by having the audio source on a separate GameObject

crimson acorn
#

AudioSource.PlayClipAtPoint creates an empty gameobject with an audiosource

jolly talon
#

Okay

#

Can you experiment by removing the destroy code and see if you hear audio

#

I've never used playclipatpoint before

crimson acorn