time.fixedtime and snake game

Hi. help please :slight_smile:
I am making simple snake game. I had attach automove of snake to time.fixedtime. But even if tt == Time.fixedTime in log, if-block doesn’t work. Sometimes works, sometimes not, to be exact.

private void FixedUpdate()  //jump
    {
        dbg();
        if (gameEnded == false)
        {

            
            //dbg();
            if (tt == Time.fixedTime)
            {
                Debug.Log("Update");
                dbg();
                transform.Translate(vcr, Space.World);
                updatepos();
                tt += 1.0f;
            }


        }

    }

FixedUpdate only executes 50 times per second. this means that sometimes Time.fixedTime will go over one before you check it. you could try
if (tt <= Time.fixedTime){
//do things();
}
which should stop the problem

ou. Thanks, it works:). One question : is it good idia to attach to FixedUpdate or there is another good way?