Help with Score
Sopanda
Member Posts: 21
in Tech Support
Hey guys. Been working with GameSalad for a week now. I figured out how to add a score counter to the game, but instead of adding a point each time, it adds 2 points instead. I've watched different videos on YouTube, it only adds one, while mine adds 2. Could you guys help me out?
Comments
We would like to help you but we can't help you without seeing your rules. I'd be guessing to suggest that you're subtracting 6 from 8 or that you have duplicate Change Attribute behaviors that are adding one twice or that you're counting the table rows in a two row table or... you get the point.
Either post a screenshot or a link to download your project and I'm sure we can get to the bottom of it.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Here's what I have. I don't know what you are saying with the 6 and 8 thing.
You're telling the actor to destroy itself and then to constrain game.score to game.score+1. Constraining an attribute to itself is generally not recommended because it introduces an endless loop (if game.score is 0, it will force itself to be one greater which is 1, and then immediately force itself to be one greater, which is 2, and then immediately 3, and ... etc.). So you've forced the score to increase constantly. It just happened that it stopped at 2 because you also are destroying the actor and it can't continue constraining the value after that.
To fix the problem, replace the Constrain Attribute with a Change Attribute behavior. That will change the attribute's value once instead of continually. Also, it's best to place the Destroy behavior last so that you don't run the risk of destroying the actor before it's had a chance to run the other behavior(s).
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Well you should be using a change attribute not a constrain.
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS
Ohhhh, Thanks I got it. Should have read what i was typing more closely
I could see from the beginning image you were using the wrong type. Check out my GSLogic series it will help you understand the basics for coding in GS.
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS