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. Join us on Thursday, June 8, for a Q&A with Unity's Content Pipeline group here on the forum, and on the Unity Discord, and discuss topics around Content Build, Import Workflows, Asset Database, and Addressables!
    Dismiss Notice

Question Long running animation stops

Discussion in 'Animation' started by BlakeSchreurs, Jan 10, 2023.

  1. BlakeSchreurs


    Aug 10, 2016
    Hey folks,

    I have an animated clock that I'm working on as time allows. In it, I have an animation of a dog walking around the clock. After a few days (usually a weekend) the dog stops animating. All the other code is fine. There are no animation transitions. The animator is extremely simple (I think it has only one state). Any thoughts on why the animation might stop after a few days?

    Thank you so much!
  2. Baste


    Jan 24, 2013
    You probably get to a time where the internal time counter becomes too large to work with floating point numbers. If you try:

    Code (csharp):
    2. [MenuItem("Temp/Test")]
    3. public static void Test() {
    4.     float oneFrame = 1f / 60f;
    6.     float threeDays = 60f * 60f * 24f * 3f;
    8.     Debug.Log(oneFrame);
    9.     Debug.Log(threeDays);
    10.     Debug.Log(threeDays + oneFrame);
    11. }
    You'll see that the second and third values are the same.

    I don't know if this is a problem with a global timer for the Animator, or just for the state. If it's just the state, the fix is simple - transition to a different copy of the state and then back again every now and again. That should make no difference visually, but would reset the timer. If it's a global Animator problem, then you'll need to Stop and Start the animator completely.