Play Random Sound for the Same Object

0 favourites
  • 5 posts
From the Asset Store
This is a single chapter from the "Construct Starter Kit Collection". It is the Student Workbook for its Workshop.
  • In Construct 2 is there a way to make it so the same object plays multiple sound files when the same action happens? So when I hit or attack something it plays multiple sound files?

  • Do you mean that on the same event e.g. Object A collides with Object B, a random sound will be played?

    If so, one way to do this is to give your sounds a set of indexed filenames like sfx_0, sfx_1, sfx_2.

    Then on your trigger event use the audio action "play (by name)"; in the audio file name field write: "sfx_"&choose(0,1,2)

    You could of course use choose with non-indexed file names e.g. choose("bang","laser","grenade"), but indexing gives you more flexibility, especially if you have a lot of sounds to pick between - you may even want to switch from using choose() to floor(random(min,max)) as this would allow you even more control over what was played.

    For bonus variation add the "Set playback rate" action directly underneath this action, setting the playback rate to a random number.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • thats actually pretty smart. id've told you to set a variable for sound played, but then youd have to say 1 = sound1 2 = sound2 3=sound3, where as indexed names you can say "sound"&Random(x,y) and it solves for the whole lot.

  • mekonbekon You my friend are a genius I was at a complete stop in my development and couldn't continue on. My main problem is I can't move on till I fix the issue at hand and you have done just that for me you are awesome and I thank you for your post. Keep up the great work.

  • You're welcome, glad to be able to help out

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)