Is there a way to randomly call sounds

TWEAmazingAppsTWEAmazingApps Member Posts: 219
edited July 2012 in Working with GS (Mac)
Hello.

I would like to know if there is a way to randomly call sounds from one actor every time the main player collides with it. And if there is a way to doit with tables. Thanks!

Best Answers

  • tatiangtatiang Posts: 11,949
    Accepted Answer
    You can randomly generate numbers. And so therefore you can randomly select table cells. What you can't do is take a number and use it to reference a sound. It is possible to generate a random sound from a list of choices provided you add rules that say When game.randomNumber=1 --> Play Sound [1]; When game.randomNumber=2 --> Play Sound [2]; etc.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • ericzingelerericzingeler Posts: 334
    Accepted Answer
    Because a sound is not an attribute, there is only one way we can go about this. In an actor, create a rule with a play sound behavior for each sound. The rule would be something like, if att.PlaySound = 3, play sound file 3. Just use a change attribute to change att.PlaySound to random(1,sound count) when players collide. In the play sound rule, be sure to reset the att.PlaySound to 0 after sound plays.

Answers

Sign In or Register to comment.