Score Keeping Issue

This is probably an easy fix, but I'm not sure what I'm doing wrong. I have a gun that fires a bullet each time I click the mouse. I added a counter on the screen, that displays how many bullets you have fired. For some reason though, if I click the fire button while the previously fired bullet is still in the viewing area, it counts it again?

So, if I click the fire button, the counter changes from 0 to 1... but if I quickly click the fire button again (and the previous bullet is still on the screen), the score jumps from 1 to 3. If I pull the trigger while 2 bullets are still on the screen, it will jump from 3 to 6...lol. Now, I'm not the smartest person in the world, but learned basic math, and that doesn't look right...lol :D

A quick rundown of how I added the score... I created a "Bullet" Integer on the "Game" tab. Then, I have a "Change Attribute" command each time the mouse is clicked, to take "Bullet" and change it to "Bullet +1".

Hopefully that enough to figure out what I've done wrong. :)

Thanks everybody, you're always such a great source of help. :D
Benjamight

Comments

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    Don't have the rule for bullet counting on the "trigger" button. Add it instead to the bullet actor. Specifically, the bullet actor should have a Change Attribute game.bullet to game.bullet+1 behavior at the top of its rule list, but without a condition (e.g. When _____).

    That way, when a bullet spawns, it adds one to the count. You can also optionally decrease the count right before the bullet is destroyed or off screen, or whatever.
Sign In or Register to comment.