Forum rules - please read before posting.

Adjusting volume over time

edited October 2018 in Technical Q&A
https://adventurecreator.org/forum/discussion/5747/how-to-change-music-volume

After reading that thread I decided to make an action which would adjust the volume over time to a new target value. However, the method specified has the nasty side effect of actually being permanent between runs of the game.  I want something like this which is temporary in nature so that if I end play mode (or my users terminate the app) it won't permanently adjust the volume.  It'd be preferable if it also wasn't something that could be interfered with by them just changing the volume in the settings menu.

What would you recommend? Thank's in advance.  

[Edit]
Here's the solution I had come up with so far:
https://pastebin.com/kq75sS7V

Comments

  • The "global" volumes are set in PlayerPrefs - so changing their values will indeed write to the system and will persist upon restarting.

    If you prevent the user from changing volumes themselves, you could feasibly hard-reset the volumes to default levels when the game beings.

    If you want to keep a volume limited to just that instance, however, you'd instead have to set the relative volume of the particular Sound component in question.  If you're trying to affect the music, and using the Sound: Play music Action to auto-generate a Music component at runtime, you can retrieve it with:


    Another option would be to rely on Audio Mixer Groups, since you can then create snapshots to override default behaviour (either using the Sound: Set Mixer snapshot Action or otherwise).  More on relying on mixers can be found in the "Sounds" chapter of the Manual.
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.