- Home /
Score Help!!!!
Hi i am working on a pong type game and the score is a timer, but the problem is im trying to reset my score to zero when i go back to title screen. My code for score: var score1 : TextMesh; static var score : int = 0; function Awake() { InvokeRepeating("UpdateScore", 0.05, 0.05); } function UpdateScore() { score += 1; score1.text = "" + score.ToString(); }
title screen is a seperate scene or just a game object in the scene?
Answer by rutter · May 28, 2012 at 07:57 AM
Because you made score
a static variable, it won't be automatically re-initialized when you reload the scene or create a new object.
The short answer is that you need to set score back to zero manually, at some point.
In the long run, you should probably study up on the difference between "static" and "instance" variables.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Ball in Pong dissapears after hitting paddle 0 Answers
Scoring System 1 Answer
Scoring not working for pong 1 Answer
Reset a timer? 0 Answers