Time.deltaTime is float but when int what is function like Time.deltaTime? (int and float) please help me?

hi guys, i have some problem…
when Time.deltaTime is float, but what same function like Time.deltaTime on int?
i want to like these…

private int score;

void Update(){
score += Time.deltaTime;
}

but my script is error… ? because i use int not float… but what the same function when i must use Time.deltaTime?

thankyou :slight_smile:

There really is no equivalent to Time.deltaTime that gives an int…nor would you really want to anyway; time increases between frames is never on the scale of seconds.

If all you want is to track how long someone’s been in game you can always use Time.time. Or you could use something like

int score = 0;

void BumpScore(){
   score += 1;
}

void Start(){
   InvokeRepeating( "BumpScore", 0f, 1f );
}

Or even

int score = 0;

void Start(){
   StartCoroutine( "BumpScore" );
}

IEnumerator BumpScore(){
   while( true ){
      yield return new WaitForSeconds( 1f );
      score += 1;
   }
}

You can’t have score be an int, because Time.deltaTime is a float. Score must be a float. So either make another variable that’s an int—maybe call it realScore—and cast score to the realScore variable, or just display score as an int using ToString formatting or another technique.

Change score to a float… Or cast Time.deltaTime to an int.