Play random sound effect

Discussion and feedback on Construct 2

Post » Thu Aug 23, 2012 7:44 pm

I tried searching and looked at the manual and couldn't find anything so I'll go ahead and post. Basically I want to play one of 3 sound effects every second. It needs to be randomly selected. How do I do this?
B
49
S
19
G
9
Posts: 430
Reputation: 9,999

Post » Thu Aug 23, 2012 8:02 pm

Use the 'Play (by name)' action in the Audio object and use an expression like this:

choose("sound1", "sound2", "sound3")

choose() picks one of the parameters at random, so it will pick a random sound to play.
Scirra Founder
B
359
S
214
G
72
Posts: 22,951
Reputation: 178,578

Post » Thu Aug 23, 2012 11:58 pm

You might also want to check the How do I FAQ

In the section "Audio" :
[quote]Play a random sound - LINK[/quote]
Which should contain some other examples capx.

New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,999
Reputation: 57,793

Post » Fri Aug 24, 2012 12:10 am

Thank you! Sorry I must have missed that!
B
49
S
19
G
9
Posts: 430
Reputation: 9,999


Return to Construct 2 General

Who is online

Users browsing this forum: bclikesyou, newt, Ragevortex, Robin Sommer and 12 guests