I’m trying to track a custom timer that matches the unity animation, such that in unity animation, when the internal time has reached frame 20 of the animation, or 0.4 seconds, it plays the keyframe on frame 20.
I have my timer increment by the same amount, such that when it has reached 0.4 seconds, it plays a keyframe as well, except before the animation update.
The problem is for some reason, I can’t manage to sync the timers due to floating point precision. Even though I’m manually updating my timer and Animator.Update with the same value, whatever is happening to the internal timer in unity’s animator is causing it to desync.
For example, after 20 frames of 0.02 increment updates, my timer is at 0.4000000001, so it correctly reaches frame 20. and unity’s animation timer is at 0.3999999999 and is still on frame 19.
Is there no way to make a timer that syncs perfectly with the internal animation timer?