Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Cannot play a audio source that is disabled error.

Discussion in 'Getting Started' started by babyboidaniel, Oct 19, 2023.

  1. babyboidaniel

    babyboidaniel

    Joined:
    Sep 5, 2020
    Posts:
    2
    Hi!
    I want to play a death sound when the player dies. For some reason this sound effect does not play due to the audio source being disabled. Every other sound effect works fine. Im lost, any tips?

    upload_2023-10-19_16-58-32.png


    upload_2023-10-19_16-58-50.png
     
  2. halley

    halley

    Joined:
    Aug 26, 2013
    Posts:
    2,276
    Debug it. Experiment.

    There are a couple odd things you have going here, so check which one it might be by temporarily removing each one.

    * you use
    Destroy(gameObject, DeathClip.length)


    Does the behavior change if you don't destroy the object, or you wait a little longer (DeathClip.length+0.1f)?​

    * right after starting a timer to destroy things, you set the
    Time.timeScale = 0


    Does the behavior change if you don't freeze game time?​

    * you use Destroy() followed by Invoke() with the same timer value
     
  3. babyboidaniel

    babyboidaniel

    Joined:
    Sep 5, 2020
    Posts:
    2
    thanks, that fixed another part of my problem. But not the initial problem. The new scene loads after the duration of the
    audioclip but it still does not play.



    upload_2023-10-19_18-11-23.png