- Home /
Number won't increment over 1.
I need to increment my int every time the player enters a zone with a certain tag.
But my script doesn't allow the number to grow larger than 1 for some reason. I think its just something simple i overlooked, But here's my code:
void OnTriggerEnter(Collider other) {
if (other.tag == "score tag") {
points =+ 1;
Destroy(other.gameObject);
scoreText.text = ""+points;
}
Comment
Best Answer
Answer by CanisLupus · Oct 25, 2014 at 10:31 AM
You should be doing points += 1
or points++
instead of points =+ 1
. Your version is simply always assigning the value +1
to points
:)
Thanks for the answer, I knew it was just a typo somewhere but couldn't point it out.
Your answer
![](https://koobas.hobune.stream/wayback/20220613165916im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Why does this increment by 2? 2 Answers
Triggering over time? 1 Answer
script not working :( 2 Answers
Random Numbers and related scripts 2 Answers
how to keep fraction number ??? 1 Answer