Why is the sound not playing in my coroutine?

Hi guys,

Why wont this sound play in my coroutine?
it works fine in start

and the print in the coroutine is working

void CheckMissionComplete()
    {
        if (bossDestroyed >= 1)
        {
            StartCoroutine(MissionCompleteTimer());
        }
    }

    IEnumerator MissionCompleteTimer()
    {
        int waiting = 5;
        yield return new WaitForSeconds(waiting);
        print("Mission complete");
        missionCompleteSound.Play();
    }

Are you sure there’s nothing else using the AudioSource? Or that the volume is at 0? Try PlayOneShot() instead.

Hi Z, but its playing when i put it in start

i even tried a condition as its all linked to update. but nothing

The code doesn’t seem wrong to me, so I’m guessing it’s something else. But you could try this instead if it seems to be working without Coroutines for some reason:

Invoke("PlaySound", 5f);

void PlaySound()
{
     audioSource.PlayOneShot(soundEffect);
}

Does that work?

The code you posted works for me, so could you maybe post a screenshot of your Audio Source? It’s probably something other than the code.

No it was my logic. The clip was playing in a loop over and over but i couldnt hear it as there is a moment silence before it starts, i changed the clip and could hear it. Got it sorted now! thanks for your help man!!!