Forum rules - please read before posting.

Feature: Extended possibilities for playing Sound objects

I was lucky enough to work on a project ( ) where we had professional help with SFX and music. While this greatly improved the feel of the game, it brought me some headaches when trying to get AC to fulfill all the requirements, especially with routing sounds through more mixer groups than AC natively supports. In the end I got it all working but some features would have definitely helped me though I have no idea how useful this would be for anyone else.

  1. Support of playing one-shots via Sound Objects. While there is an action for playing one-shots, this relies on playing audio clips and thus you have no control over the mixer group which this one-shot goes through. Using the Sound:Play action does not allow for playing the sound in multple instances simultaneously, if you trigger it while the sound is still playing, it just restarts the clip from the beginning. I solved this by creating a new Sound Action script extended by this functionality, basically I just added a modified Play method since I wanted to be able to play clips referenced in the Sound object's Audio Source as well as to play audio clips referenced in the action. I always kept Sound type as Other since both Music and SFX mixer groups had multiple sub-groups. I can supply the code if you're interested though it definitely needs some polishing, I only had a few days to implement it all. :wink:

  2. Support of playing Music and Ambience via Sound Objects. Similar as above, to be able to control the mixer group which Music and Ambience clips get routed to.

  3. Support of Audio Clips as parameters to Action Lists. We have a lot of interactive objects throughout the game that emit a sound when triggered. The sound always goes through the same mixer group. I came up with a pattern where I instantiated a Sound Object prefab in all scenes and in Action Lists I played audio clips through this Sound Object via my custom Play Oneshot function referenced in item 1. However many of these sounds had variations that were to be randomly selected. I wanted to create a parametrized Action List for this but the problem I had was that Audio Clips cannot be referenced as parameters. I had to either create Sound Objects with Audio Clips attached and play those in the parametrized action list or randomize on the spot wherever I needed this, both methods had their drawbacks obviously.


  • edited January 28

    Thanks for the feedback

    1. I was under the impression that an AudioSource can only play one sound at a time. If that's what you mean by "the Sound:Play action does not allow for playing the sound in multple instances simultaneously", I'm not sure could be done - though you're welcome to PM me your code to elaborate.
    2. Music/Ambience Actions are necessary for the music/ambience tracks to be saved correctly. If you have no need for that, you can have the tracks be played through regular Sound: Play Actions. Are you looking to give different tracks different Mixer Groups?
    3. Audio Clips can already be assigned to "Unity Object" parameters. This parameter type can be used to override audio fields in the Sound: Play and Sound: Play one-shot Actions.
    1. AudioSource.PlayOneShot() actually doesn't cancel clips already being played, see I'll send you the code via PM.
    2. Yes, I wanted to play different tracks via different Mixer Groups. I had a separate Mixer Group for ambience, which was a subgroup of SFX and I had different subgroups of music for intro and ingame music. In the end I used a combination of playing ingame music via AC music actions and ambience via Sound: Play
    3. I didn't mention this explicitly in my first post but it was mainly about the New clip field in Sound: Play - that is the one that accepts Audio Clips and it cannot even be parametrized. You can only use game objects to override the Sound object field in Sound: Play Action...yes, you can assign an Audio Clip to the object when it contains an Audio Source but you can't assign an Audio Clip to a parameter that requires a game object. Unity just won't allow me to do that.
    1. I will introduce the ability to override mixer groups per-ambience/music track, in that case.
    2. The "New clip" field takes a Unity Object parameter - not a GameObject. If you're encountering an issue with this, share some screenshots and I'll try to see what's wrong.
    1. Thanks a lot for that. :smile:
    2. Wow, the Unity Object option totally slipped my issue with anything else but my eyesight here. :smiley:
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.