Trying to set up dynamic music fade in and out based on distance from Player to AI

Hi, I’ve very new at programming, and I’ve been trying to make a game similar to Dark Deception.

I’ve been completely stuck on setting up chase music for days now. What I need it to do is when you are within a set range of one or more of the monsters, the normal track fades out, and the chase track fades in, and vice versa when you are outside of all monsters range. It fades in just fine, but I just cant get it to fade out. If anyone has any ideas on how to make this work, that would be amazing.

Hi OGDavidBaron,

Try adding a “Fade Out” of the audio component that’s not what you want playing along with the “Fade In” of the one you do want playing.

Hi RecourseDesign,

I tried that, but for some reason when the chase starts, it goes completely silent? Unless I’m doing it wrong, I just set up a “Fade Out” that connects right off of the “Fade In” of the opposite song…

hmmm - can you put a snapshot up with the extra Fade Outs?

What are the Track Components? They mention Cues but Cues don’t have audio components - are you sure that the 2 audio components being referenced from them are not in fact the same object?

I’m not quite following, are you asking if the Normal and Panic tracks are referencing from the same object?

Have you tried using the CrossfadebyDistance node? I use that for aircraft and just plug an empty wave player in when it’s out of range to hear.

I did look at it once, but I couldn’t get it to work. So far what I have now is the only method that has actually functioned, everything else either didn’t play any music, never switched music, or played both tracks at once…

What happens if you test if both the audio components are the same - it’s just that it’s acting like they are so it’s always good to eliminate the possibility:

1 Like

I think I tested it correctly, they don’t seem to be the same, I never got the print

1 Like

Ok, yeah I need some sleep :smiley: It’s getting faded in and out all the time - add some code to make sure it only fades in and out when an enemy has come within range or all have left, but not all the time…

1 Like

alright, thanks :slight_smile:

1 Like