Forum rules - please read before posting.

Sound fade

edited February 2021 in Technical Q&A
Hello,

We want to make sounds (all sounds) fade when game pauses. Not stop abruptly, but fade. Any idea where to look at?
I know how to fade sounds in game, but when it pauses AC stops sounds automatically.
Thanks.

Comments

  • Sound: Play action set Fade out time there.

  • @SkyTree I'm looking for another thing, not in Actions but inside AC.
  • AC doesn't directly pause sounds when the game is paused - it's built-in behaviour of any Unity AudioSource that doesn't have ignoreListenerPause checked.

    If you want to run some custom code at the time the game is paused, you can do so by hooking into the OnEnterGameState custom event, i.e.:

    void OnEnable () { EventManager.OnEnterGameState += OnEnterGameState; }
    void OnDisable () { EventManager.OnEnterGameState -= OnEnterGameState; }
    
    void OnEnterGameState (GameState gameState)
    {
        if (gameState == GameState.Paused)
        {
            //
        }
    }
    

    For audio to fade out when paused, you'd have to enable ignoreListenerPause and then manually pause the sound once the fade out has completed. You'll make things easier for yourself if you instead fade out the sound and then pause the game.

    One way to do this would be to play audio through Audio Mixer Groups, and then apply a Mixer Snapshot using Actions to transition to a snapshot that makes the audio silent, just before pausing the game.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.