- Home /
Audio volume problem?
Hi,
I have an in-game pause menu which allows me to adjust the volume level by adjusting the AudioListener from 0 - 1 via a GUI slider. This works as expected for the other audio elements in the game, except when I press my shoot button the gunshot volume is unaffected. The AudioSource is attached to a game object with the shoot script where the sound is played when a ray hits the enemy collider.
Has anbody encountered this problem before?
If your Listener is on your camera and that camera is close to the player, you may need to play with the roll-off graphs.
Answer by ragnaros100 · Sep 03, 2013 at 12:44 PM
Have you checked that your gunshot sound is'nt a 2D sound?
Go to Import settings to change it :)
Answer by gfitz82 · Sep 03, 2013 at 01:14 PM
Got this working but I don't know if its the best solution..
I get reference to the game object with the AudioSource,
private var shoot : AudioSource;
function Start()
{
shoot = GameObject.FindGameObjectWithTag("Bullet").GetComponentInChildren(AudioSource);
.
.
.
}
then I set the volume of this AudioSource to match the value of the AudioListener,
function ShowAudio() {
GUILayout.Label("Volume");
AudioListener.volume = GUILayout.HorizontalSlider(AudioListener.volume,0.0,1.0);
shoot.volume = AudioListener.volume;
}
Probably not the best way but it works!
Your answer
Follow this Question
Related Questions
sound too low in Android devices 0 Answers
What is the exact equation being used for sound volume? 0 Answers
How do I only start the audio when player is at max distance 1 Answer
AudioListener.volume doesn't change the volume 4 Answers
Volume Slider 0 Answers