Make Music Fade Away?

0 favourites
  • 10 posts
From the Asset Store
6 looping tracks to use in your games and projects. These tracks are in the style of the 1960s detective movie genre.
  • I want to make music fade out on command. How do I go about doing this. Any help will be appreciated!

  • create a global variable called musicVol and set it to 0 or whatever the volume is supposed to be ( goes from 0 decibels to -infinity I guess )

    create another variable called fade = 0

    have an event that sets music volume to the value of this global variable

    Then on your command set fade variable to 1

    create another event: if fade = 1 > every 0.1 seconds subtract 1 from musicVol variable. That would reduce music volume by 10 decibels per second, need it to fade faster set it to subtract 1 every 0.05 seconds or whatever fits your game.

    I would also put some limits here. if musicVol<-100 set fade to 0 again so it stops fading because you can't hear anything at -100 anyway.

    You can also bring it back up again, same way, just set fade = 2 and add event that if fade = 2 ads 1 to musicVol every 0.05 seconds, and if musicVol>than 0 and fade = 2 set fade back to 0 and musicVol back to 0, so it stops at 0 decibels

  • create a global variable called musicVol and set it to 0 or whatever the volume is supposed to be ( goes from 0 decibels to -infinity I guess )

    create another variable called fade = 0

    have an event that sets music volume to the value of this global variable

    Then on your command set fade variable to 1

    create another event: if fade = 1 > every 0.1 seconds subtract 1 from musicVol variable. That would reduce music volume by 10 decibels per second, need it to fade faster set it to subtract 1 every 0.05 seconds or whatever fits your game.

    I would also put some limits here. if musicVol<-100 set fade to 0 again so it stops fading because you can't hear anything at -100 anyway.

    You can also bring it back up again, same way, just set fade = 2 and add event that if fade = 2 ads 1 to musicVol every 0.05 seconds, and if musicVol>than 0 and fade = 2 set fade back to 0 and musicVol back to 0, so it stops at 0 decibels

    I did something like this before posting this, and I was having audio issues. What do you think the cause of this is?

  • What kind of issues?

  • Yeah, you would need to explain the issues. I am still on Construct 2, but it should work the same way. Always worked without issues for me.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Yeah, you would need to explain the issues. I am still on Construct 2, but it should work the same way. Always worked without issues for me.

    The audio starts to gargle the moment I issue the command. The volume still fades out, but the audio gargles.

  • Sounds like you are replaying the music each time with a lower volume, rather than using "Set volume" with a tag.

  • Sounds like you are replaying the music each time with a lower volume, rather than using "Set volume" with a tag.

    Nope. Here's a picture of my code.

    https://www.dropbox.com/s/urgp0f9rtat9n ... s.png?dl=0

    The only other code related to the music is when you you finish a level, or pause the game, the music stops, which I checked to make sure that they weren't overlapping. They are not.

  • http://www.blackhornettechnologies.com/Construct2Stuff/aqunex2_musicfade_bht.capx

    Ahhhh... I see... My mistake was I wasn't setting the volume every time I subtract from the dB.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)