WaitForSeconds little trouble

function AddScore()
{
scoringIsActive=true;
enterTime=Time.time;
while(tempScore>0)
{
scoreNumberTxt.text=score+“”;
tempTxt.text=“+”+tempScore;

    		if(Time.time-enterTime<1.0) yield WaitForSeconds(0.5);
    		else yield WaitForSeconds(0.001);
    		tempScore--;
    		score++;
    	}
        scoringIsActive=true;

}

The idea of it that i want to slowly subdivide tempScore and add score for a second then do it very fast… there was another algorithm that used Time.time, but it didnt work, too!

Have anyone an idea?

Wouldn’t it be both easier and faster to use:

var newScore = Mathf.Lerp(score, score+tempScore, Time.time);
score = newScore;

I’ve not tested this script yet, but it should do what you want. In order to add some value to the score, just store the value to add in tempScore: the score will rise in a slow pace and after reach the time defined in slowTime it will go up 1 per frame

private var lastScore:int =-1;
private var nextTime:float;
private var slowTime:float;

function Update(){

if (tempScore>0){
  if (tempScore>lastScore){
    lastScore = tempScore;
    nextTime = Time.time;
    slowTime = nextTime+2; // slow for 2 seconds
  }
  if (Time.time>=nextTime){
    scoreNumberTxt.text=score+"";
    tempTxt.text="+"+tempScore;
    if (Time.time<slowTime)
      nextTime += 0.5; // slow pace
    else
      nextTime += 0.001; // fast pace
    tempScore--;
    lastScore = tempScore;
    score++;
  }
}