Setting up ambient sounds with a day/night cycle

Hi everyone!

I am currently have issues trying to get ambient sounds playing during my day/night cycle. I can get the correct sounds to play at the correct time however they never stop playing and end up overlapping each other. I have tried a few things suggested but I haven’t managed to get it working correctly.

These are my day/night cycles (currently working fine) and the last is my current attempt at setting up an ambient sound to match time of day (e.g. birds during the day, crickets during the night)

Thank you in advance!

1 Like

Like this ( I have a feeling of deja vu :wink: ):

And finally:

No worries, just come back if you get stuck!

BTW, if you think it looks like a bit of a fiddle, take a look at this ( below ), I tried it with the do once nodes! ( it works but still generates one null variable error ):

Yeah, sorry about reposting this, I tried to set up what you showed me orignally but i had no luck.

I will give this a try.

Thank you!!

Hi - it’s the lack of target that’s causing the problem. Drag the pin from the sound playing variable and look for ‘get sound’:

303052-target.jpg

Awesome, thanks. This is what I have so far. I start my project at 0 (12 midnight) and it plays the night sound but never updates to a day sound, also the night sound doesn’t cut off at 6am as specified. What am I missing? I couldn’t find a Target | Sound node. My day/night sound variables are Sound Base as a veriable type and my Sound Playing veriable are set as Audio Component as a variable type.

Ok cool, I found it and plugged it in, look all correct now but still the same issue. Plays night sound from 12 Midnight when I play my project but doesn’t update to day sound

Ok, well the logic definintely works ( I have pressure tested it ). What I’d suggest is hack it so you can choose when to switch ( don’t wait for the time ), just put a couple of key presses in like this:

So you can switch at the drop off a hat. When you’re satisfied the swapping works, you can rummage around in your code a bit…

I will take another look at the rest of your code now…

It might be that you are apparently implementing a 24 hr clock, but in the day/night test you seem to only have a 12 hr clock…

OK, I’ll give this a try after work tonight. Thanks for you’re help =)

No worries - we will get there! :slight_smile:

Hi there, sorry it took my a while to get around to this. I have given that a try and nothing happens on the keypress.

Excellent :slight_smile:

Did you enable input?:

Ok, yes, enabled that and switching is working perfectly. I think I may have identified an issue but may not be related to this specific issue however may create further issues with the time of day sound. When i play and it hits 24 hours it doesn’t reset to 0 it just continuesly climbs, I was thinking this might cause issues with it looping as I have the time variable to to 0600 and 1800. Thanks for getting back to me so quickly as well!

I have the same problem setting an ambient sound for day and night.
I can’t get the target variable “get sound”
What kind of variable is “sound playing”?

It’s always a good idea to create your variables by right clicking on the output pin :slight_smile: