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
55
S
22
G
11
Posts: 446
Reputation: 11,610

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
367
S
217
G
82
Posts: 23,269
Reputation: 183,883

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
258
S
90
G
48
Posts: 7,087
Reputation: 62,910

Post » Fri Aug 24, 2012 12:10 am

Thank you! Sorry I must have missed that!
B
55
S
22
G
11
Posts: 446
Reputation: 11,610


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 5 guests