Forum rules - please read before posting.

Audio - controling volume of sounds played in c#

Unity Ver: 2019.4.18f1
AC Ver: 1.73.8

Hello,

I'm starting to add a few sound effects into my game. The vast majority of these are played in action lists, but player sounds are done from various C# classes.

I want to ensure that all sound effects abide to the volume level set via the AC options menu in game. How would I ensure the sounds played in scripts respect that?

Thanks!

Comments

  • The easiest way is to rely on AC's Audio Mixer Groups option, which controls volume by adjusting the attenuation of individual Speech/SFX/Music mixer groups. Including custom audio in those volume controls is then just a matter of assigning the appropriate mixer group to the AudioSource.

    This tutorial covers the process of working with mixer groups.

  • edited August 2021

    Thanks Chris. All up and running in less than 15 mins. Another win for AC!

  • Bonus side question @ChrisIceBox; someone popped up and asked would it be possible to alter the volume slider using the mouse scroll wheel. Is that a bit too advanced for a pure AC menu?

  • You can't control an AC Slider directly that way, but if you update the volume directly then the element should update to reflect the change:

    float speechVolume = AC.Options.GetSpeechVolume ();
    AC.Options.SetSpeechVolume (speechVolume);
    
    float sfxVolume = AC.Options.GetSFXVolume ();
    AC.Options.SetSFXVolume (sfxVolume);
    
    float musicVolume = AC.Options.GetMusicVolume ();
    AC.Options.SetMusicVolume (musicVolume);
    
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.