random sounds

i have ob “man” and ob “bullet”. if man gets hit by bullet i want it to play a random sound out of 3 of my sounds. How do i do this?

Hmmm… my idea would be to attach three sound actuator logic bricks to a python controller… and this python controller to the collision sensor (or whatever sensor you use) and make the python randomly choose from the three sound actuators…

… OR… you could have a complex set of logic bricks doing this for you too…

Have a “Bool” property called “Play”… set it to False
Then create an “Int” property called “Sound” or something like that… and set it to… 1

This way you can use the random actuator to randomly set the “sound” property, and set the “play” property to true everytime the object is hit…

And then through a set of property sensors (or expression controllers) you can play the sound and change the “play” property back to “false”…

Just ideas…

how would i go about using the random actuators? Should i use the random actuator or sensor? ive tried them but couldn’t get them to work.

You want the random actuator. The random sensor is just an Always sensor that fires at pseudorandom times.

To use the random actuator in the way you want, set the dropbox to “Int Uniform”. Next, set the seed at anything other than 0. Then you set the min and max of the numbers gerenated and the property these numbers go into.

To set up the bricks, do this: When the enemy gets hit, the random actuator goes off. Sets of bricks detect what the property’s value is and play a sound. Then the property is reset to 0 so only one sound is heard.

Here is a blend.
Hope this helps.All logic brick.
I love logic bricks!

http://www.megaupload.com/?d=L8NKRGYY

thanks that worked! :smiley: