Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Time factor is changing and getting wierd when I leave the Unity program open too long

Discussion in 'Editor & General Support' started by six5hot, Dec 10, 2014.

  1. six5hot

    six5hot

    Joined:
    Nov 6, 2014
    Posts:
    10
    I am having an odd problem. I am working on a 2d game. I have some sprites that I am having move on a preset pattern using lerp.

    To be exact here is one of the statements:

    this.transform.position = Vector2.Lerp(this.transform.position,Vector2(this.transform.position.x-1,this.transform.position.y) , speed);

    If I open Unity (Windows 7 / Unity 4.6) at first everything works exactly as I programmed it. But after Ive been working on things for a couple of hours or even if I just open Unity and walked away for a few hours and came back to it, all the sudden the sprites that I have moving using the lerp function no longer move the normal way. They start moving much faster or in other sporadic and odd ways. Also I don't think its just lerp I have a sprite moving using a

    this.transform.Rotate (Vector3.forward * -1);

    and after a while it starts rotating in jerky ways vs smooth.

    Whenever this happens all I have to do is restart unity and everything works normal again, at least for a while.

    What is very strange is I need to close Unity and restart it to fix it. If I just hit the play button again things are still weird. I would think every time you hit the play button it should reset all the variables and start the game fresh, so it does not seem right that I need to close the program and restart it to get back to normal.

    Does anyone know what might be causing this?
     
    Last edited: Dec 10, 2014
  2. six5hot

    six5hot

    Joined:
    Nov 6, 2014
    Posts:
    10
    Well, I seemed to have figure it out. The problem was the move scripts needed to be in Fixed Update vs Update. That made all the difference.
     
  3. SantosR

    SantosR

    Joined:
    Dec 18, 2013
    Posts:
    27
  4. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,398
    Definitely don't use FixedUpdate if you're not using physics. It doesn't match the screen update rate, so it won't look as good.

    --Eric