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
72
S
24
G
11
Posts: 452
Reputation: 12,385

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
399
S
236
G
89
Posts: 24,542
Reputation: 195,428

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
294
S
117
G
96
Posts: 7,311
Reputation: 71,086

Post » Fri Aug 24, 2012 12:10 am

Thank you! Sorry I must have missed that!
B
72
S
24
G
11
Posts: 452
Reputation: 12,385


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 9 guests