Need a way to play one SFX at a time

KrisBeeKrisBee Member Posts: 6
I'm working on a project with many different touch events. A problem arises when the user touches an actor once to trigger the audio for that (first touch) event, then quickly touches a second and/or third time triggering the SFX specific to those events. Creating only very short duration SFX will go a long way towards addressing the issue, but it isn't always a workable solution.

Is there a way to ensure only one SFX audio will play at a time; having the playing audio stop when another starts?

Kris

Best Answers

  • jonmulcahyjonmulcahy Posts: 10,408
    Accepted Answer
    Use play music instead of play sound.

    Sounds can be stacked
    Music can only play one at time
  • SlickZeroSlickZero Houston, TexasPosts: 2,870
    Accepted Answer
    The only thing I can think of is to use the "play music" behavior for the sounds like jon suggested, and use "play sound" behavior for the music. The music would have to be less than a minute I believe, (possibly 30 seconds? I can't remember off hand) and looped to work properly, and you can then use the "stop music" behavior in your buttons to stop the current sound, and use "play music" after that to start the new one.
  • theCodeMonsterstheCodeMonsters Posts: 359
    Accepted Answer
    This would be a last resort but, here's what I would do.

    1. Make a global Boolean set it to true
    2. Make it so that the sound will only play (in addition to your other conditions) if the boolean is true
    3. Once the Rule is met, with the behavior of the sound playing, set the boolean to false.
    4. Set a timer for however many seconds you want of delay, and after X amount of seconds set the boolean to true again.

    Do this for all of your sounds and only one should play at a time.

Answers

  • SlickZeroSlickZero Houston, TexasMember, Sous Chef Posts: 2,870
    Have you unchecked the "run to completion" box in the play sound behavior?
  • KrisBeeKrisBee Member Posts: 6
    Yes, I thought of that except.... you guessed it.... I want music too. The music needs to play throughout. Thanks for the suggestion.

    Kris
  • KrisBeeKrisBee Member Posts: 6
    SlickZero, yes, I did try that as well. Unfortunately it made no noticeable difference.

    Thanks to both for the replies

    K
  • SlickZeroSlickZero Houston, TexasMember, Sous Chef Posts: 2,870
    edited April 2012
    That would work for playing one sound at a time TCM, but what I believe he is trying to do is pre-empt a sound that is currently playing, and have the new sound take over immediately.
  • KrisBeeKrisBee Member Posts: 6
    I'm looking forward to trying out the suggestion of playing sound in music channel and vice-versa. I'm not at home now but will try it when I am.

    Thanks
    Kris
  • KrisBeeKrisBee Member Posts: 6
    Playing the SFX in the music channel does stop the previous SFX to play a new one. It doesn't seem a very elegant fix and I will have to see what other issues arise as a result. I need to play a different music track for example, depending on the scene. As TCM mentioned, audio play can be controlled using attributes; I tried this briefly and found I can indeed stop one (sound) track to play another depending on attribute values. I am a little confused however, because after trying this with SFX as sound, I had no success. Nevertheless I'm confident I will have a solution I can work with, elegant or not. I'll post again later, once I am sure of which route works best, in the hopes that this thread may help someone else as it has definitely been a great help to me.

    Thanks again
    Kris
Sign In or Register to comment.