Answer the question
In order to leave comments, you need to log in
How to adjust the volume using the slider?
I am adjusting the volume of music and effects, I found several video examples, I repeat as there, but the result is different.
public AudioMixerGroup Mixer;
public void ChangeVolumeMusic(float volume)
{
Mixer.audioMixer.SetFloat("MusicVolume", Mathf.Lerp(-80, 0, volume));
}
Answer the question
In order to leave comments, you need to log in
You should at least look at the documentation for what Mathf.Lerp is before blindly blindly copy-pasting the code from the video: https://docs.unity3d.com/en/2019.4/ScriptReference... . You absolutely do not need lerp here, because if you set t less than one, then when you try to set the volume to 100 (or another number), you will have it less than 100. And if t is equal to 1, then there is no point in linear interpolation. replace with just volume. Mathf.Lerp(-80, 0, volume)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question