AudioSource refuses to Play

I have an audio source that’s assigned in my script. In the update function, I have the following code:

if (CoverTimer < 0.5f && SndCoverMove != null && !SndCoverMove.isPlaying)
{
    SndCoverMove.Play();
    Debug.Log("Play cover sound");
}

When I run the game, the sound does not play, and the log shows about thirty instances of “Play cover sound”, one frame after another. So, even though Play() is getting called, isPlaying never gets set to true.

I’ve tried setting the sound to “Play on Awake” and it plays fine then, but not when called from code, so the actual AudioSource is set up correctly, and so is the clip that’s assigned to it. I’ve tried setting the audio source’s priority to 1, with no effect.

This is driving me crazy… I’ve been using Unity for a long time now, but I’ve never seen the audio source silently fail like this before. Does anyone know of any arcane conditions that I may be missing to get this to work?

Edit: Found the problem. When the audio source was created, it was duplicated from another audio source. Another script, for whatever reason, decided to keep a reference to the duplicate rather than the original, so that completely unrelated script was preventing it from playing. Thanks for the help and sorry for wasting your time.

Audio Source Screenshot

I think there’s a host of Arcane sound bombs out there. Such as null references in some other script…forgot to drag a prefab into a slot. etc…could be wrong… Sometimes I try to set a timer instead of checking to see if it is playing, I can’t remmeber now but it seems like that check to see if Audio is playing, never worked… i’m not an expert, if it ever was buggy, maybe it’s fixed now, I am curious to see where this all goes.

Read through the other convo you’ve had…

That does seem weird and like a bug… but I’d think if it were a bug, a lot more people would be complaining about it. So, a couple guesses…

You sure your AudioSource reference is the right one? Double check… maybe even re-drag it in or if you don’t do it through property inspector, be very sure you’re finding it correctly.

You sure you don’t accidentally stop the source each frame too?

One other suggestion for troubleshooting purposes only… drop your current logic for playing the sound, and use a bool… set it to false initially. Play the sound when this is false, and then set it to true. Again, just to troubleshoot. You should hear your sound once this way.