Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Audio if (AudioClip.isDonePlaying == true)

Discussion in 'Audio & Video' started by Huxii, Feb 21, 2021.

  1. Huxii

    Huxii

    Joined:
    Sep 15, 2018
    Posts:
    32
    Hello,

    I trying to setup audio in my game and had to find out, that there is no method for finding out, if an audio clip (or animation) is simply done playing. Instead of that, there are several "workarounds" which means creating additional "helper code" or even create a new Script/class for that.

    There is a method .isPlaying, which I tried to use too, but unfortunately this is also true, when the audio haven't started yet, so it doesn't help at all. So, Unity, if there is a method isPlaying, why is it not possible to create a method isDonePlaying? What is the "official" solution for that from your point of view.

    Thanks
    Huxi
     
  2. LethalInjection

    LethalInjection

    Joined:
    Jan 25, 2015
    Posts:
    36
    I wrote an audio manager that has multiple sources, and just find one where Audio.IsPlaying is false.
    This works well since multiple effects can be played at the same time. Just don't play the exact effect at the same time or volume will be doubled.