Audio not playing on TriggerEnter (Pic Included)

Hi, i’m trying to make it so when my player character enters a gems trigger it plays a sound, destroys the gem, then sets the playerpref to 1. But I can’t get the sound to play?

Can someone take a look at this and tell me why the sound might not be playing.

Try adding a Rigidbody2D (isKinematic set to true) to the Gem.

if you play a sound and delete the object, the sound will NOT be played. Delay the Destroy() and the sound will play!

Thanks to chariot for the hint!

Use a coroutine for your sound. In some cases on trigger enter only actually has an effect for that brief moment the trigger is entered.

You could try using OnTriggerStay instead (depending on your needs)

Personally I would just add something like -

start coroutine PlayTheSound() (add this line to your OntriggerEnter event)

Then make another function -

void PlayTheSound()
{
   //**insert your sounds line of code here**
}