GUI Counter

Hi!

I am making a game like the game Cookie Clicker and when I get the powerups, they give me score each second. But my problem is. If I want it to give 5 points per second, it goes like 0, 5. I want it to count those numbers like 0, 1, 2, 3, 4, 5 but it still takes on second.

Here is the powerup code:

var cookieGenerateAmount : float = 1;
var timer : float = 1;

function Start () {
	Generate();
}

function Generate () {
	while(true){
		yield WaitForSeconds(timer);
		Score.score += cookieGenerateAmount;
	}
}

I’m not really clear about your variables in your script as it is a class execution only in start.

If you run it in start then it won’t update very frame so it will be impossible to increase by +1 until 5. You need to run it in an update.

What I would do is create a checkup with a sub counter
for instance if your main subcounter is not equal to the main counter subcounter +1;

Then add the subcounter to the score.score. simply use the main counter as an ifstatment limitation so the subcounter does not go out of bounds when adding up to the score.score.