Forum rules - please read before posting.

Sound Play Across Scenes not playing every other time

edited August 2021 in Technical Q&A

Hi everyone, I'm Juan and this is my first post here. I'm super enjoying my time with Adventure Creator, I have created a few scenes already and I can't believe it is such a GREAT tool! (Thanks Chris for that!)

I'm having a problem I could not find an answer that works here on the forums.

I need to have a sound playing on a loop on a scene (it's an SFX, not ambience, it should be triggered on top of the ambience after meeting certain condition). Then I want that loop to keep playing when I do a Switch Player and go to the other scene where Player2 is. And then I want the loop to persist when coming back to scene #1 (Player1). Makes sense?

The problem is the sound loop starts ok, keeps playing on scene2, but when coming back to scene1 it stops. BUT if I go again to scene2, then once again back to scene1, THEN it works. I mean, the first time you go back to scene1 it doesn't work, the second it does, and so on (each second in a series).

I have the sound as a GameObject, with the Audio Source, Sound and Constant ID components. I have moved this SoundObject to the top of the hierarchy, and made it a prefab.

From my OnStartCutscene, where I trigger the sound to play on a loop, I'm using "Sound: Play" action, and IF dragging the SoundGameObject form the hierarchy into the Sound Play action's input, I get no console warnings.

But if I drag the Prefab right from the Project folder, the times where it does not play I get the following message:
"Can not play a disabled audio source" . (As stated before, this only happens every alternate time).

If anyone could provide any help I would be super thankful for that!!

I'm using Unity 2020.3.16f1 and AC's v 1.73.8

PS: I also tried to re-trigger within the OnLoad cutscene with the same result :S

Sound Object Screenshot:
https://drive.google.com/file/d/1QyCWtEWXpFyq0roayD6V4v6Eyy3Vu_SB/view?usp=sharing

OnStart Cutscene:
https://drive.google.com/file/d/1BtExDZ8t7GKGSm0ik6Bk-iaobBZN9YnI/view?usp=sharing

OnLoad Cutscene:
https://drive.google.com/file/d/1QyCWtEWXpFyq0roayD6V4v6Eyy3Vu_SB/view?usp=sharing

Comments

  • Welcome to the community, @juanmaguerrero.

    I'm afraid your third screenshot link is a duplicate of the first - can you re-share your OnLoad cutscene image?

    The "Can not play a disabled audio source" message will play if an attempt is made to play the audio from a prefab directly. This will occur if you assign the prefab in an Action, but an instance of the prefab is not found to be in the scene at the time.

    If you have a Sound object set to survive scene changes, then re-entering the scene it came from will mean you end up with duplicates as the Sound gets loaded in again as part of the scene data. If you're getting random behaviour from this point, it may be that which of these duplicates are then controlled by Actions is then chosen at random.

    Try keeping the Sound object as a prefab and out of the scene file, and then using the Object: Add or remove Action to spawn it in at the moment you wish to play it.

    However, if there's a way you can leverage the Ambience/Music systems here (such as playing it as a Music track), I'd recommend doing so. Controlling audio across multiple scenes can be tricky in Unity, hence AC's dedicated features for doing so as Ambience/Music.

  • Hi, @ChrisIceBox thanks so much for your help!

    Just to update my original post, here's the 3rd image again:
    https://drive.google.com/file/d/1JSQ6TM810Q2LGobDM9nRcNXbsguE8wgR/view?usp=sharing

    But, yes, I understand what you say. Before I posted here, I thought of switching between ambiences to solve it in a faster way, and now that you confirm it will be less messy, I will go with that option.

    So, thanks so much for the explanation!! And for your amazingly fast response and care about helping others.

    Best regards!

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.