Random Sound Generator

In my game, I'm trying to generate a random sound upon clicking an actor. I set an integer for the scene known as (random sound). When I click the actor through The Change Attribute command I change the scene attribute (random sound). The Change Attribute command generates a random integer [random (1,7)]. A different sound is produced for each integer. However when the random number chosen is same as the previous number for example (1 and 1) the sound will not play again. It looks to player the game has crashed. How can you get the same sound to be played when the attribute has not changed by the change attribute.

If I could think of a command, It would be If change attribute generates a integer equal to the previous integer replay sound 1.

Can I do this by manipulating another attribute a boolean attribute or perhaps a table?

Thank you,

Seven Note.

Comments

  • tenrdrmertenrdrmer Member, Sous Chef, Senior Sous-Chef Posts: 9,934
    you could put the play sound rule inside your touch rule after the change attribute so every time it gets touched it fires the sound the its set at.

    I would put it in a timer for after 0 or after 0.1 with run to completion checked that way it works even if the button is not held long enough for the rule to run completely.
  • tutysestutyses Member Posts: 134
    Or you can use a boolean, enabling and disabling it every time you trigger the rule or when you press the button.
Sign In or Register to comment.