Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Bug Changing audio source clip, but audio doesn't play.

Discussion in 'Audio & Video' started by LagiaDOS, Oct 26, 2023.

  1. LagiaDOS

    LagiaDOS

    Joined:
    Mar 5, 2021
    Posts:
    1
    Hi, I'm trying to make small script that changes the music depending on the level (due to unrelated reasons, every level uses the same scene but it's modified with a script). The audio clip is changed, but it doesn't play. What am I doing wrong, and why doesn't the sound play?


    The part of the script that involves the audio
    upload_2023-10-26_10-6-3.png

    The object with the script and the audio source (The listener is in another object, I already checked it and it works)
    upload_2023-10-26_10-7-29.png

    After executing the script.
    upload_2023-10-26_10-8-43.png
     
  2. Hikiko66

    Hikiko66

    Joined:
    May 5, 2013
    Posts:
    1,306
    Where is your code playing the source?
     
    SeventhString likes this.
  3. EcstaticWalter

    EcstaticWalter

    Joined:
    Nov 28, 2021
    Posts:
    2
    Have you tried right after the line: m_MyAudioSource.clip = audioFacil; wirte this line of code: m_MyAudioSource.Play();