- Home /
scale animation result?
Hi,
I have a little animation that fades in different music tracks from volume 0 to 1. works fine, but I want to allow the user to set the MusicVolume. I'd multiply the musiVolume with the desired volume but how can I do this when using the animation system? So that in the end, the volume isn't 1 but 0.5, depending on the MusicVolume?
Answer by tingham · Feb 13, 2012 at 04:06 PM
Store your music volume setting as a float from 0f to 1f and multiply the animated value by that property value. Make sure that you set your new volume constant in some other place besides Update; otherwise your volume will diminish over time.
Options for this would include:
Having a master controller object that retains your volume settings; when the GUI is updated by the user, pipe your new values into this controller. In your update loops in the various components where volume is consumed you'd then use the constant value.
Implement events and use a delegate to apply the change to your volume.
How am I gonna do this? If I just do track.volume=track.volume*musicVolume, the volume will get less in every frame if there is no animation playing :/