x


AudioListener.volume doesn't change the volume

Hi everyone ! I've made a custom 3D Slider with a box you can slide here is a part of the code

function FixedUpdate () {

VolumeSonore = ((gameObject.transform.position.x - 266.57) * 15.953)/100 ;

AudioListener.volume = VolumeSonore  ;

print(VolumeSonore);

}

so when the box in on the left side of the slider , it prints 0 and when it's on the other side it prints 1 , but the sound doesn't change (there is just a music attached to the main camera).

Actually , when it's on the left side , the music sounds more laggy , but actually as loud as on the right side .

Thanks for reading

more ▼

asked Aug 25, 2011 at 09:06 PM

Anykey gravatar image

Anykey
16 35 24 26

Could your audio source be using ignoreListenerVolume?

Aug 25, 2011 at 09:18 PM aldonaletto

No it's not using ignoreListenerVolume , i've tried adding a script to the camera which makes the ignoreListenerVolume false and true , but both doesn't make it work :/

Aug 25, 2011 at 10:27 PM Anykey

Is your sound 2d or 3d in the import settings?

Aug 25, 2011 at 10:45 PM Tyler 10

my sound was 3D in the import settings , but I changed it to 2D and the volume is still the same when I move the slider :/

Aug 25, 2011 at 11:46 PM Anykey
(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

I've tested this script and it worked fine. My scene is different, so I had to adapt the numbers - in consequence, the volumeSonore value ranged from -0.5 to +7, but this value is internally clamped to 0..1, so it worked as expected.
I suspect there's something else altering the volume. Could you have some other lost script changing the volume elsewhere? Try to create a new scene and place only the essential objects to see if it works.

more ▼

answered Aug 26, 2011 at 01:04 AM

aldonaletto gravatar image

aldonaletto
56.8k 31 77 291

I feel so dumb , the script was applied at another object I forgot about , I thought the only fact that it was printing the good value would be enough .

Thank you so much !

Aug 26, 2011 at 11:21 AM Anykey

This happens very often: scripts forgotten or attached to wrong objects by mistake are hard to find, and may bother us to death

Aug 26, 2011 at 11:37 AM aldonaletto
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x5871
x1601
x155
x107
x53

asked: Aug 25, 2011 at 09:06 PM

Seen: 2516 times

Last Updated: Aug 26, 2011 at 11:37 AM