How to play a sound every time the attribute game.score change

LordTarantorLordTarantor Member, PRO Posts: 890
edited November -1 in Working with GS (Mac)
Hi everybody:
I am trying to add a sound every time the score goes up but I just cant figure it out. I tried to put in the score actor where the display text is, a rule that say when attribute game.core = to game.score+1 play sound. That does not work.
Can some one tell me what the rule should be? or how to do this?

Comments

  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    you can try when gamescore is not equal to 0 play sound.

    or whatever rule you have the changes the score have a play sound as well.

    so if you have when actor collides with bullet change score to score +1 , add a play sound it that rule
  • JlmCJlmC Member Posts: 129
    when game.score = 1 should work.

    game.score = game.score+1 i think its wrong
  • ScootsScoots Member Posts: 507
    JlmC said:
    when game.score = 1 should work.

    game.score = game.score+1 i think its wrong

    No because game.score = 1 only happens once if it's game.score +1 it will change each time the score goes up.
    you also can put a overlap or collides on the actor that triggers the game score to go up. so that when it is touched by the object causing the score to change it also plays a sound. I did that on a pinball type scene.
  • LordTarantorLordTarantor Member, PRO Posts: 890
    Thanks guys.
    The thing is that I have now hundreds of instances of a prototype, so I will have to go to every single one of them to add the rule to make the sound. That is why I am asking if there is a way to do it directly in a rule when the score changes.
    I tried when the score is not equal to 0 but it did it only one time because then the score was not 0.
    Is there anothe way?
  • ScootsScoots Member Posts: 507
    Maybe a control actor off the scene & invisible

    attribute game.score = game.score +1

    Play sound
  • LordTarantorLordTarantor Member, PRO Posts: 890
    Thanks Scoots but I tried that one and it does not work.
  • ScootsScoots Member Posts: 507
    hmmmm, just to double check is your score only going up by 1 or is it something else 10,20,30 whatever.

    if it is something else then the rule needs to be adjusted accordingly.

    game.score = game.score + ? (whatever you are using)

    play sound
  • LordTarantorLordTarantor Member, PRO Posts: 890
    yes the score goes up by +1. I put a rule that said when game.score = game score+1 play sound.
    That one doesn't work.
  • ScootsScoots Member Posts: 507
    I wonder if this is a bug in 0.9.1? because that should work
  • spliketspliket Member Posts: 93
    I'm not so sure the game.score+1 should work...

    I mean, mathematically, the score can never = +1 of itself. right?

    i think you would have to sample the score every 0.1 seconds or so. then, compare that to the actual score.

    so, create a second game attribute. something like game.compareScore (can't think of anything better at the moment).

    Timer (Every 0.1):
    change game.compareScore to game.Score

    Rule:
    if game.Score = game.compareScore+1
    play sound

    or
    Rule:
    if game.Score does not equal game.compareScore
    play sound

    not sure which would work better for you....haven't tested it, but i think this would work.
  • LordTarantorLordTarantor Member, PRO Posts: 890
    spliket... That was the bomb
    Thanks a lot.
    I used the rule when game.score is not equal to game.comparescore.
    It works amazing.
    Thank you
Sign In or Register to comment.