Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only. On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live. Read our full announcement for more information and let us know if you have any questions.

Bug (SOLVED) Strange behaviour when animating AudioSource volume (Unity 2021.3.11f1)

Discussion in 'Animation' started by ethansanderson0, Jun 7, 2023.

  1. ethansanderson0

    ethansanderson0

    Joined:
    Oct 21, 2020
    Posts:
    5
    EDIT: Turns out I had somehow changed the animator layer to additive without realising, and since no other layers affected the AudioSource the volume was being added to the default value.

    Hi, I'm getting some strange behaviour when trying to change the volume of an AudioSource through animation.

    Firstly, the value of the volume in the animation seems to be adding to the default value set in the inspector, instead of overriding it. For example, I have an animation that changes the volume gradually from 0 to 0.1, which works fine when the volume was originally set to 0 in the inspector. However, when the volume is originally set to 0.5, the volume then instead animates from 0.5 to 0.6, seemingly adding the values defined in the animation.
    This isn't that much of a problem since an easy workaround is just to make sure the volume is originally set to 0 in the inspector before performing any animation. However, this clearly isn't an intended behaviour since the value for volume in the animation can only be in the range 0-1, meaning it can never be decreased below its original value.

    Secondly, the volume will only change during an animation if the first frame of the animation has the volume set to 0, otherwise the volume will be set to the default value and not change. This, combined with the first issue requiring the default value to be set as 0, means that no sound will be heard at all without making sure the first frame of every animation initially sets the volume to 0.

    I'm not sure whether this is an issue with the animator, or something to do with the internal workings of the AudioSource, but any help or insight would be greatly appreciated :).
     
    Last edited: Jul 8, 2023