k_holla
k_holla

Reputation: 35

Why does my audio mixer sometimes adjust the volume when I press A/D while playing?

Why is this happening and how can I make it stop?

Like the title says, sometimes pressing A/D on my keyboard while playing my game adjusts the volume, when I just want A/D to move my player character left and right and have no effect on the volume.

Background Information: I followed this tutorial to setup my audio volume slider UI element : https://www.youtube.com/watch?v=YOaYQrN1oYQ&t=122s

Here is the code for my volume slider:

public class MasterAudioSlider : MonoBehaviour
{
    public AudioMixer audioMixer;

    public void SetVolume(float volume) => audioMixer.SetFloat("volume", volume);
}


I have four UI buttons set up so that when each one is clicked it cycles through toggling groups of audio sources on/off, cycling back around to the first group of audio sources. I can post the code if further clarification is needed.

Here's what I know so far (please excuse the formatting, it's supposed to be a single-level bulleted list):


- Pressing A decreases the volume, D increases it.

Getting the problem itself to occur is kind of finicky. I'll try my best to explain.

Sometimes it'll change the volume and then get stuck at that volume level, and sometimes the problem just magically goes away even when all of these "conditions" are met!

Since the slider is the only UI element that's directly "connected" to the audio mixer and the problem stops once the audio mixer is not linked to the slider or is completely disabled, I'm thinking the culprit is the audio mixer itself. Which leads me to the question: why would an audio mixer take input from the keyboard where none has ever been specified??

I'm really hoping it's just some checkbox I missed.

I'm happy to post more of my code upon request for further clarification; I didn't want to bog down this post with walls of text.

Upvotes: 1

Views: 502

Answers (1)

juliushuck
juliushuck

Reputation: 1694

Maybe in your input settings A and D are setted to set the value of the slider or for the axis and the axis will set the slider. Like Enter is setted to submit a button or so.

You can solve it by setting the navigation on your slider to None.

Set Navigation to None

Upvotes: 2

Related Questions