- Home /
Question by
Gragger · Apr 23 at 07:30 PM ·
timefixedupdate
time.fixedtime and snake game
Hi. help please :) 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;
}
}
}
Comment
Answer by GreasySam · Apr 24 at 02:54 AM
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
Answer by Gragger · Apr 24 at 08:49 AM
ou. Thanks, it works:). One question : is it good idia to attach to FixedUpdate or there is another good way?