How do I make random sound on same event

Get help using Construct 2

Post » Tue Feb 02, 2016 3:49 pm

Hi,
I want to make random sound on same event. For example, when my or enemy player get hurt, it makes a different sound from few pre made sounds.
Any idea on this issue?
B
4
Posts: 17
Reputation: 234

Post » Tue Feb 02, 2016 3:53 pm

you would have to set a global var to select sound

on event set random var

system compare var

if var play what ever
B
29
S
13
G
10
Posts: 355
Reputation: 8,317

Post » Tue Feb 02, 2016 4:26 pm

How set the global var to select a sound?
B
4
Posts: 17
Reputation: 234

Post » Tue Feb 02, 2016 5:27 pm

on event sheet right click

global = sound

if sound = 1 play song
if sound = 2 play song
if sound = 3 play song

and so on.
B
29
S
13
G
10
Posts: 355
Reputation: 8,317

Post » Tue Feb 02, 2016 6:15 pm

another way of doing this is a function with a parameter, (think of this as a switch) in the function you create parameter 0, 1, 2, 3 etc and each one plays a sound

in your code that will call that sounds just call the function with parameter (choose(1,2,3,4,5,6) or how ever many you have.
B
8
S
1
Posts: 72
Reputation: 721

Post » Tue Feb 02, 2016 6:33 pm

I'll try this.
Thank you for both 2 great anwsers
B
4
Posts: 17
Reputation: 234


Return to How do I....?

Who is online

Users browsing this forum: Christmas and 2 guests