Search Unity

Audio [SOLVED] playOnAwake Audiosource only playing when looped.

Discussion in 'Audio & Video' started by Bdelcast, Jul 9, 2019.

  1. Bdelcast


    Jul 11, 2014
    Sorry, I made a post asking this same question in the scripting forum, but I realize now that this is probably the right place to post it.

    I have a situation that is really frustrating me. I have used this same method several times, it's not a complex setup, but it simply won't work in this specific scenario, and I can't pinpoint the reason.

    I have a prefab of a gate, it has an audio source in a disabled game object in its hierarchy.This audio source game object is enabled via an animation when the player walks close to the gate.
    the object is set up like this:
    The system works as expected, when the character walks to the door it plays the animation, and it opens or closes the gate accordingly. HOWEVER, the audio will NOT play, even though the audiosource is set as "play on awake" and the gameobject IS being enabled in the editor.
    All other audio in the game works fine, and even other audio triggered in similar ways work too.

    the audio in the prefab is set up like this:
    Weirdly, I found out that if I do set the audiosource to "LOOP" as shown on the image above, the audio DOES play, but I don't want this sound to be looping. No matter what audio clip is set, it will not play when not looped.

    I have tried with an intermediary script triggered from an animation event as well, but although the method is also triggered, the audio source will not play, no matter what. I've set the volume and the range of the audiosource to be exaggeratedly large, to test, but nothing.
    As i said, with the script, the functions are also triggering as expected, debug shows calls to the audiosource.Play() function too, and It shows in inspector as well.

    I am at a loss as to what could be causing this.

    I recently updated to unity 2019.1.9f1, but I'm not sure if this is a documented issue.
    Is this a bug? does anyone have any idea as to why it could be failing?
    Last edited: Jul 9, 2019
  2. Bdelcast


    Jul 11, 2014
    After a lot of testing and resetting and restarting, the issue simply cleared itself just now.
    Now it is working as expected.

    I have no idea what solved it.

    One of those things, I suppose.