Forum rules - please read before posting.

How to temporarily change music volume

edited November 2018 in Technical Q&A
Is there any way to change the volume of music tracks?

I'd like to temporarily set the volume up or down for a cutscene, but there is no action for. As far as I know it is possible to use custom script, but there are two problems:
1. You can only change the global music volume.
2. You cannot fade it smoothly.

The first problem is that changing global music volume overrides user settings. I thing the idea here is that the global music volume should be set by the user and not changed by the game. The alternative solution is to set an individual track volume, but it is still not perfect and can lead to more problems.

The second problem is much more difficult to beat. Most of the times we want the music volume to go up or down smoothly over some time, not immediately.

It is very easy to do with regular sounds, but music does not have that option. So here's another solution: don't use the music system at all, use a sound in a gameobject. However, this is an ugly solution and it does not work, if you want your music to play in more than one scene.

Help! Am I missing something obvious here? Why there is no feature to set the music volume with fade, just like it is done with regular sound?

How can I set music volume up or down smoothly during the gameplay?

Comments

  • If you rely on Audio Mixer Groups for audio playback, you can implement a Snapshot with a raised volume.  That snapshot can then be blended to over time using the Sound: Play mixer snapshot Action.

    See the Manual's "Sounds" chapter, and Unity's documentation, for more on Audio Mixer Groups.  Once you've created ones for SFX, Music and Speech, create a new "MasterMusic" group and make it a parent for the Music.  That way, you can control the volume of "MasterMusic" and in turn the global music, without affecting the user settings.

    Then create two snapshots - one default, another with MasterMusic's volume dipped.  You can then use the Action above to transition between them.
  • Ah, good idea!

    Thanks, that should do it. I've completely forgotten about Audio Mixer Groups. I'll explore this further.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.
Do NOT follow this link or you will be banned from the site!