Search Unity

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

Discussion in 'World Building' started by Geoffroditis, Jan 11, 2019.

  1. Geoffroditis

    Geoffroditis

    Joined:
    Nov 6, 2017
    Posts:
    1
    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

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    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.