Forum rules - please read before posting.

Playing a looping sound whilst a menu is open.

On my save and load menus , I want to have a sound looping whenever the menu is open. I achieved this by adding an action list asset to the field in the menu settings named "Action List when turn on" and adding a Sound:Play action set to loop with the required sound clip. This works as required however the sound continues to play after you exit the menu.
I assumed that creating another action list asset for the "Action list when turn off" field and using an Action list : Kill action would stop the sound when you exit the menu but it does not.
Can somebody please explain how to do this correctly.
Thanks in advance.

Unity Version : 2019.4.1f1
Adventure Creator version : 1.70.2

Comments

  • The ActionList: Kill Action will only stop an ActionList - and the Actions within it - from running. Once the sound has started playing, the Sound: Play Action has been completed so is no longer running.

    You can use another Sound: Play Action, however, to stop a sound by setting its Method value to Stop.

  • Ahh ok I understand. Thanks for explaining. Appreciate the help.

  • Hi @ChrisIceBox , sorry but I am having some strange issues - I really have no luck with sounds in AC....
    So basically , I tried to do what you said , and setup the sound:stop action. But with the sound:play action , I had simply dragged the sound file into the actions "new clip(optional)" field as this seemed to work without having to setup a prefab. However , the sound:stop action only stops sound objects so I had no way to stop the sound playing.
    I then assumed that I should make a sound object prefab for this action , so that It had a constant ID and was not stored locally in a scene so I added a new sound object to the open scene with the AC scene editor and dragged it into my assets folder to make it a prefab. I added the sound file to the sound object and then dragged the object into the sound:play actions sound object field. However , when I tested the game , the sound did not play. I really don't think Iv'e got the grasp of sounds and after reading the sound section of AC's manual I am still no further forward.
    Not only that , but in the process , something has happened that has stopped all of my menu screens hover and click sounds from now working :

    The thing is , I can't set the "play while paused" checkbox because when I set the sounds , I just clicked the little circle next to each field and chose the sound clip required from my assets folder:

    This was all working fine , but now it isn't and I have no idea why it happened or how to fix it...
    As always , I appreciate any help you can give me.
    Unity Version : 2019.4.1f1
    Adventure Creator version : 1.70.2

  • Unity cannot play a sound from a prefab - whatever Sound you select needs to be in the scene. It can still be an instance of a prefab - but the Action needs to refer to an object actually in the scene.

    The same goes for the "Default Sound" field that is assigned in the Scene Manager. The messages in the Console are referring to a GameObject named "Sound_Default" - this should be present in your Hierarchy.

  • Ok thanks @ChrisIceBox , so should I make a scene specifically for the in game menus to reference from? As the menus will be the same throughout the whole game then I assumed that the sounds played in the menu should be global and stored in the asset folder rather than a scene.
    Also , when I choose a sound for a menu , for example the "hover" sound , and I click the circle next to the field to open up the list and pick a sound clip - what exactly is happening here? I just thought I was selecting the sound files from the asset folder but is AC setting these up in a scenes default sound in the background or something?

  • should I make a scene specifically for the in game menus to reference from?

    It'll need to be in the scene that's currently loaded. If you're using a prefab, you'll need to place an instance of that prefab in each scene. Try it with one test scene and see how you go before extending to others.

    what exactly is happening here? I just thought I was selecting the sound files from the asset folder but is AC setting these up in a scenes default sound in the background or something?

    All menu sounds are played via the scene's "Default Sound", which is just a regaular Sound object that is listed in the Scene Manager.

  • Perfect , I've got t all figured out now and working properly. Thanks again @ChrisIceBox !

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.