How do I change the sound volume of a SoundClass in code?

I have a Master SoundClass and its children are Music, Environment, UI, and SFx. I’d like to change their volume in code but I’m not sure where to begin. I tried this…


exec function SetMasterVolume(float NewVolume)
{
	local SoundClass Master;
	Master = SoundClass'soundclassesandmodes.Master';
	Master.Properties.Volume = NewVolume;
}

…and that doesn’t seem to do anything. Any advice?

I can do this so far, and this works just fine…


exec function SetMasterVolume(float NewVolume)
{
	local AudioDevice Audio;

	Audio = class'Engine'.static.GetAudioDevice();
	Audio.TransientMasterVolume = NewVolume;
}

But that only controls the master volume. I think I know where to look to control volume by SoundClass. I’ll come back when I have it figured out.

Edit:

OK, I figured it out. It’s PlayerController.SetAudioGroupVolume(). Give it the name of the sound class and the volume you want it set to. In the editor make sure your sound cues are set to the right sound class.

yep, that’s how it works :slight_smile: