Differant Sound Depanding On the Time of day

Hello i got a Question

i have a day night cycle with the time based on minutes let say 60 RL minutes a a full cycle

no is the thing that i whant to have two differant ambiance sounds during the night/morning and late morning and day

so :
from 18:00 till 10:00
&
from 10:00 till 18:00

On the screenshot is wat i tryed and did not work
the audio played at the start when the time was manualy set to for example 18:00 but did not swap with the time hit 10:00 or the other way around

also tryed it on event tick but than the audio didnt play at all

any ideas on how i can make it work ?

thank you in advance

It’s because you connected it to begin play. That only happens once.

On begin play, you need a ‘set time by event node’ which checks once every 5 seconds ( for example ), if it’s time to change the sound.

1 Like

I Tryed that after i posted the question
this didnt work

1 Like

1 Like

oke this one kinda works the only problem with this is it doesnt stop the other sound so the play both
and it keeps spawning the the sound every check
and when its passes 10 it stays day sound is will not spawn back to to night sound

1 Like

Nuke it.

nukeIt

Bind a custom event to tick, after it executes/spawns the sound, unbind it. You’ll need to track the time at the tick event to know when to bind/unbind. This should be the only thing this tick event will do, so change the tick interval to something higher like 1 second or more so it doesn’t check time every frame.

can you show a example that will be great its my first time trying to get this to work

Sure.

Now that I think about it: branch and a couple of do once should suffice with the tick.

I’ll try both later tonight and post here.

1 Like

oke thanks this part is even harder than the daynight cycle it self XD

1 Like

Might have complicated it a little… Here it goes:

  1. Set tick interval time. If isMinutes = true → 3600/24 = 150 seconds (2:30 minutes). This makes 24 ticks in 1 hour. for test did 60/24 = 2.500 seconds…

  2. Next is update the clock.

  1. Check time.

*3.2. Inside the macro

*4. What hapens after time macro here

  1. For ambient noise/music

This is the entire thing:

This is the result.

If you don’t need the clock and REALLY need to get rid of the ticks every 2.5 seconds, you can change tick interval once every d/nigh change. For example: you start at 5, set tick interval for 5 seconds, when it runs at 10 change it to 8 so it runs again at 18, then change again to 16 to run it again at 10… etc

Hope it helps.

2 Likes

Got the math wrong here at the conversion of current time to 24 hours…

if 1 hour is full day cycle → 30 minutes = 108000 in game seconds for 12 hours / if 1 minute cycle → 30 seconds = 30 in game seconds for 12 hours. This is the math for conversion:

Wanted to finish this. Think I’ll end up using it. :innocent:

3 Likes

thanks a lot ill try this tomorrow

1 Like