Search Unity

  1. Unity 2018.3 is now released.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. We've updated our Terms of Service. Please read our blog post from Unity CTO and Co-Founder Joachim Ante here
    Dismiss Notice
  4. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  5. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice

How can I make background audio change with the time of day?

Discussion in 'World Building' started by Geoffroditis, Jan 11, 2019 at 3:37 PM.

  1. Geoffroditis


    Nov 6, 2017
    Hello, I am working on designing an environment for my class, and I wanted to know if it was possible to make a script or function where I can have a background clip play for day time and a different one play at the night. I do already have a day/night cycle.

    I attached the day and night cycle script below.

    Attached Files:

  2. JoeStrout


    Jan 14, 2011
    Sure, why not? You could have two AudioSource references, and call .Play on the appropriate one. Or, you could have a single AudioSource and two AudioClip references, and then assign the appropriate clip to the AudioSource before telling it to play.

    I guess I'm not clear on exactly what the difficulty is you're having.