Forum rules - please read before posting.

Ambiance and background sounds

I've found myself going around in circles with this one. Typically I try to research the issue as much as possible before jumping to the forum to ask questions, but this one has burnt me out. 

I have two ambient sound clips of light wind, and several wood creaks and rope creak clips. My goal is to have the wind ambient clips looping constantly, with a fade in and out between the two as they start and stop suddenly. Then I want to randomize the various creak sounds to play throughout as well. 

I saw this post and I understand how to use the action editor to randomize the creaks 

However, I have found myself going in circles because I simply don't understand how the sounds are actually played through an action list. 

Do I add and empty game object and then add an action list component and a play sound action?
Do I add a sound prefab and then add an action component to it?
Or is there another method?

Then I read something about certain sounds causing save issues which confused me more. 

Also, can both the constant ambiance from the two wind clips, and the random creak clips be all integrated into one action list, or do they have to have separate ones?

Additionally, I did manage to get the ambient wind clips playing with the above cut scene method to play music, but it played one, followed by the other and then stopped..... I tried looping it by taking the output of the final clips node and plugging it into the first, which I assumed would work, but it just made the game crash. 

One final question about action lists. does the final node in the sequence need to be set to "stop" or "continue" after running because that always confuses me. 

I'm very new to all this, and Iv'e watched both Chris Burton and Isaac Lundgren's tutorials and read through the manual , but this ones got me stuck

Thanks in advance for any help. 

Comments

  • The object on which ActionList/Cutscene etc components are placed is independent from the object's they affect - you don't need to place them on the sound objects.

    Essentially, there are three ways of playing sounds:

    1) The Sound: Play Action - this plays AudioClips with AC's Sound prefab, which you can create in the Scene Manager.  A Sound object can be given an AudioClip to play by simply having it assigned in the AudioSource component, but the Sound: Play Action can optionally set the clip when it runs.  You can save the audio playback's state by attaching a Remember Sound component to the Sound object, and optionally have it survive scene changes (though it'll be destroyed in the new scene when it stops playing).

    2) The Sound: Play one-shot Action - this plays an AudioClip without the need for a Sound object or AudioSource component.  This makes it more convenient to play, but you aren't able to control the audio settings as you would with 1), nor save its playback state.

    3) The Sound: Play music Action - this is a separate sound system that handles audio playback automatically, without the need for a Sound object, and also works automatically across scenes.  With the exception of crossfading, however only one "track" can play at a time.

    The 3D Demo game makes use of method 1) for e.g. the opening cutscene Intro1, and method 2) in the cutscene SkipIntro.

    As ActionLists are separate from the objects they affect, you could move all Actions to one - but it may be more convenient to handle the creaks and wind in two separate ones (or at least work on one before incorporating the other).

    I suspect that your crash was because you created a looping ActionList that ran indefinitely every frame - the Sound: Play music doesn't wait for the chosen track to finish, so the two looping Actions would have been cycling between each other as fast as your CPU would allow before running out of memory.

    Since you need the two tracks to play in an indefinite loop, I wouldn't recommend using the music system - at least not with two tracks like that.  You could try editing the wind sounds in e.g. Audacity to add in fade ins/outs directly, and then have an ActionList play one sound (Sound: Play), wait a second or so less than it actually lasts (Engine: Wait), and then fade in/out the new sound/old sound respectively.

    About ActionLists: the "Continue" option will only have an effect if it is not the last Action in the sequence - it'll behave like "Stop" otherwise.  It is recommended to use the ActionList Editor window over the ActionList Inspector, as that makes it much easier to visualise the flow of Actions.
  • Thanks for such and in-depth explanation @ChrisIceBox , that really clears things up for me. 
    Ill have a play around with your suggestions and let you know if I get stuck again. 
  • edited November 2017
    @ChrisIceBox , I've had a play about with what you suggested with varying results :

    I managed to get the ambiance looping very nicely by using Audacity to fade and crossfade several ambient wind tracks into on. I then added an empty game object to mu scene, added an audio source and an audio listener component and dragged the clip in to the audio source's "audio clip" field. I then set it to loop and when tested, it works fine. 

    However, I am having less luck with setting up an action list to play randomized creaks. To achieve this , I tried adding one of AC's "sound" prefabs. As a test , I dragged the clip into the audio source's "audio clip" field and ran the game, but the creak did not play. I tried adding an audio listener component, but still no luck. I compared what I had, to my ambiance game object setup I mentioned above and it seemed the same. While I was looking at my ambiance game object, I swapped out the ambient track for the creak and it played, so It can't be the actual track. 

    Am I missing something? My goal here is to have the creak (and several others) playing through an action list so I can use actions to randomize them like you showed in this example : https://www.adventurecreator.org/forum/discussion/738/play-sound-every-random-x-seconds 
    but neither the sound prefab on its own, or adding an action list sound:play seem to work. 

    Additionally, some things that confuse me when using the action list to play a sound, is that the Sound:Play action asks for a game object. Do I drag the sound prefab into this? And the new clip optional field? Is this clip to replace the sound clip that is in the audio source components  "audio-clip" field? And if so , why would you add a clip in there and then replace it in the action list play:sound?  

    Thanks for any help you can offer. 

    **EDIT** I enabled "play on awake" on the sound prefab's audio source component, which  played the creak once , or looped it if I enabled that checkbox too, but I still can't get the check random number variable - engine wait - Sound:Play action list to work for it. I added the component "action list" to the prefab, but it is just getting ignored. Does it work like a queue  and need to be moved up above the audio source component in the inspector? And how does the action list relate to it? Sorry for my confusion but I can't get my head around the proper way to use an action list correctly and how they work. 
  • ActionLists generally shouldn't be added manually - normally you should just use the Cutscene prefab listed in the Scene Manager, and run it via other Actions (or with the "Run now" button if testing).  The location of the ActionList component has no bearing on the objects it affects.

    What is your game's SFX audio set to, and have you marked your Sound object's "Sound type" to match?

    The Sound object (in the scene, not the original prefab) should be assigned in the Action.   The optional clip field will replace its AudioSource component's Audio clip field.  Its not necessary if you want one particular clip to play at that point, which is usually beneficial if you're dealing with 3D audio and want each sound to be positioned correctly.

    Your scene should only have one AudioListener component (Unity will complain otherwise), and this is on your MainCamera by default and shouldn't need changing.

    The Actions you've described should work, so I'd recommend using Action comments to help debug what's going on.  The "cog" icon to the top right of an Action in the ActionList Editor can enable comments, and these can be displayed in the Console (when the Action is run) via an option at the bottom of the Settings Manager.  Make use of this to determine if the Sound: Play Actions are being correctly run or not.

    However, the recent v1.60 update also includes a new "Ambience track" system, which behaves very similarly to the Music system only for SFX tracks.  Tracks can be queued up, crossfaded etc, so you may want to consider using that instead, since it does away with the need for working with Sound objects completely.
  • edited November 2017
    Ok thanks @ChrisIceBox

    First up, is there any kind of manual that covers all of this so I could read through it and stop pestering you on here? Ive clicked on the "sounds" section of the tutorial navigation bar that is found here : https://adventurecreator.org/tutorials/making-2d-game , but that only covers playing music. 

    Secondly, you mentioned the ambience track system in 1.60 , I have updated but where do you find this? I assumed that It would be done similarly to the method found here : https://adventurecreator.org/tutorials/managing-music-across-scenes but I couldn't see anything that mentioned ambience in the music storage window , or the sound:play action. 

    Also, I seem to be getting somewhere with the random creaking sounds. The action is working to the point where the variable check number chooses a pause time, and then plays the sound, but then wont play it again. Looping in the audio sound component just loops the soind indefinitly and ignores the action, and looping the sound:play action does nothing. I just need the action to keep repeating over and over so that the check random number variable keeps pausing the sound with a random time delay so that the creak plays throughout the scene at random times. 

    So to sum up my two current questions : 
    1. where do I find the new ambience track system for my ambient wind sounds, 
    2. How do I indefinitely loop my action list to play the creaking sounds at random times throughout the scene duration? At present the action is set up as you demonstrated in an old topic but with a sound:play action in place of the dialogue : image


    Also , another thing that has confused me, is that you mentioned that you don't typically add action lists manually, you would use an add cutscene prefab.... but in a earlier reply, you said "1) The Sound: Play Action - this plays AudioClips with AC's Sound prefab, which you can create in the Scene Manager.  A Sound object can be given an AudioClip to play by simply having it assigned in the AudioSource component, but the Sound: Play Action can optionally set the clip when it runs."
    However, AC's sound prefabs do not have an  action list when you add them, you would have to add one manually if you were to want to do what you said , which you also warned against doing. Have I misunderstood you there ?
     
    Sorry to be a constant nuisance, I was getting on nicely with my game until I got to the sounds and have hit a wall. Again, thanks, and if there is a full manual on AC , please point me in the right direction and I will happily read through it before pestering you further....
  • First up, is there any kind of manual?

    Sure - a sizeable manual can be found in the root Adventure Creator directory, and is also available online.

    Secondly, you mentioned the ambience track system in 1.60, I have updated but where do you find this?

    Use the new Sound: Play ambience Action, which is totally separate (but similar in functionality) to Sound: Play music.  This is covered in the Manual under Section 5.13, and also listed in the Changelog file.

    How do I indefinitely loop my action list to play the creaking sounds at random times throughout the scene duration?

    The example screenshot will play the same subsequent Action (the dialogue) regardless of the chosen random number - the only thing that changes is how long the delay is.  As each random sound has its own length, you'd want each of the outputs for the Variable: Check random number to link to their own separate Sound: Play Actions, followed by their own Engine: Wait Actions, which then re-route back to a single, shared Action that loops back to the Variable: Random number Action.

    image

    AC's sound prefabs do not have an  action list when you add them, you would have to add one manually if you were to want to do what you said , which you also warned against doing. Have I misunderstood you there ?

    I wasn't saying the ActionLists get added to the Sound object - just that the ActionList (regardless of where it is) can assign a Sound's AudioClip when it runs its Sound: Play Action.  See the image I've provided above - here, the same Sound is being played, but with a different clip each time.  The ActionList itself can be anywhere in the scene.
  • Ok , so I read through the manual and I am beginning to get my head around this more and more. 

    My misunderstanding was that I thought you had to have an action list on a sound object , but in reality you have your sound objects with their clips attached, and you can call upon those sound objects through the sound:play action which can be on action lists on various objects in the scene such as cutscenes for example yes?

    I also had a play around with the ambience system that you mentioned in the update. I got it working by adding a cutscene and then using the action list for that cutscene with the sound:ambience action , and added my ambience tracks to the ambience  storage window. Did I do this correctly? 
    It worked, as it played through the ambient tracks as required, but I did find one weird thing : Whenever the ambience is playing, it cancels out any other sound objects that are playing. For example , I had a rope swinging , and a random creak playing fine, but when I added the sound:ambience, they went quiet. They were still trying to play as I could see the various nodes in the action list that were randomising the creaking lighting up green , but the actual sound was not playing. There is a VERY slight sound of them for a millisecond before the ambience kicks in on game start, but then the ambience begins and it seems to mute all other sounds......

    My other issue is how to play several sounds at once with action lists. What I mean by this is say for example I want to have 1. my ambience , 2. a random creak , and 3 . a random wind gust playing throughout the scene, then I would need 3 action lists to play them yes? (or maybe two if you have the sounds in the same list as you showed above, but you would still need a seperate one for ambience if I understand right)  But it seems to me that you can only have one cutscene playing from the start (determined by the "on start" cutscene chosen in the scene manager) , but then how do you call upon the other action lists to play the other random sounds? I get that you can have several sound objects set to "play on awake" in their respective audio source components , but that will just play them as soon as the scene starts either once or looping yes? So what if you want several random sounds and an ambience track playing through action lists from the start of the scene? 

    Finally, regarding my last question, CAN you actually use a single cutscene and action list to play both the sound:ambience and sound:play actions so that a single action list can play both ambience and random creaks and wind gusts? I am familiar with node systems as I use Blender 3d a lot, but in those I am used to being able to branch several noodles from one node to control several other nodes.Is this sort of behavious possible in AC's action lists to achive what I suggested? 
     
    Thankyou again for your continued help and patience whilst I get my head around this. 
  • The issue you raise about other sounds being cancelled when using the ambience engine is a bug - thanks for bringing it to my attention.  I'll see that it is addressed in the next update.

    As for your ActionList arrangement, there's no technical requirement to have your Sound: Play ambience in a separate ActionList - though it's often easier to break up your ActionLists if they get complex.  While each Action output can only connect to one input, the ActionList: Run in parallel Action can be used to run multiple subsequent Actions (or ActionLists) simultaneously.
  • Ok cool ill give it a go thanks . 
    Also, I'm glad I have helped you out in return a little after all you have done for me with your advice.  
  • Sorry for bringing back this topic... needed the same thing...
    I think I've made everything works, BUT, I've one problem: the "engine: wait" at the cutscene doesn't allow me to play the game (i.e. cursor is not appearing).
    Why so? Looks like everything is stuck waiting for the "engine".
    I thought it was some kind of background actions...
    Basically I want my cutscene to start by playing music, playing ambience and randomize in loop a thunder sound.

    Here a screenshot: https://ibb.co/MnVwDp1

    Basically the "thunder" is randomize correctly, but the cursor won't appear...
    Why so?

  • What of your ActionList's properties? You'll need to set its When running field to Run In Background to prevent it from blocking gameplay.

  • Thanks! It worked! Sorry for the noob question!

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.