# Float to Int

What am I doing wrong here? I just need to var checker to have no decimals…

``````var checker = 0;
var checkerSpeed : float = .03;

function Update(){

//a timer
checker += Mathf.FloorToInt(1 * Time.deltaTime * checkerSpeed);
``````

Thank you!

Mathf.FloorToInt returns zero because deltaTime is a small number. Do it this way:

``````var checker = 0;
var checkerSpeed:float = .03;
private var checkerAc:float = 0; // time accumulator

function Update(){

checkerAc += Time.deltaTime*checkerSpeed;
checker = Mathf.FloorToInt(checkerAc);
``````

You want checker to go up at intervals?

``````var checker = 0;
var interval = .3;

function Start () {
InvokeRepeating("IncreaseChecker", 0, interval);
}

function IncreaseChecker () {
checker++;
}
``````

(As an aside, there’s never any point to multiplying something by 1. Something * 1 = something.)

You can’t actually compare real numbers to integers, so just stick with one or the other. If you using the reals, you’ll have to use Mathf.Floor or something similar.