Quantcast
Channel: Questions in topic: "twice"
Viewing all articles
Browse latest Browse all 70

Int increased twice and not only once

$
0
0
Hi, I have a scoreboard in my simple football game, and i want to increase team's score by 1 when the ball passes the goal line. But when it goes in the cage, the score increases by 2, like 0-0 to 2-0... Here's my Update method : void Update () { lol = transform.position.x; int caca = Team1Score-1; if (lol <= -84.4) { Team2Score++; resetBall(); } else if (lol >= 84) { Team1Score = (Team1Score +1) + Team1Score - (caca); resetBall(); } else { Team1Score = Team1Score -1; } text.text = Team1Score + " - " + Team2Score; } If i don't put the second and third else, the score increments to the infinite.. Someone knows why ? Thanks for your help.

Viewing all articles
Browse latest Browse all 70

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>