Closed GoogleCodeExporter closed 9 years ago
Hi Marcos,
that is not a bug. As you can see, the last result is as you expected (the X is
not 0 but almost infinitely next to it, so is considered 0 - that number is due
to floating point imprecisions that are due neither to HOTween nor to Unity,
but simply to every CPU), because the tween is complete and thus is at the
perfect end of a loop. For the rest instead, you will never have the exact "end
of loop" result you expect during an OnStepComplete callback, because HOTween
uses a very high precision tween calculation, and doesn't simply complete a
loop and wait the next frame to restart it, but calculates the correct time and
starts a loop before the next frame if needed.
Let me explain better. Let's say we have a tween of a simple number called
someNum, which goes from 0 to 1 and loops 3 times. Let's also say that we have
a slow framerate, and each frame takes 400 milliseconds to elapse.
1st frame: 400 MS have elapsed, someNum is 0.4
2nd frame: 800 MS have elapsed, someNum is 0.8
3rd frame: 1200 MS have elapsed, OnStepComplete is called. But the value of
someNum will be 0.2 this time, since we already stepped in another loop and
restarted the tween.
I worked a lot to implement this feature. Without it, each loop cycle would
"waste" some milliseconds at each completion, while waiting for the next frame
to restart. This means that 1000 loops of 1 second each won't really last 1000
seconds, but 1000 seconds + all the wasted time. With this precise tween
calculation instead, no time is wasted, and 1000 loops of 1 second each will
last 1000 seconds :)
Original comment by daniele....@gmail.com
on 17 Dec 2012 at 6:58
"and doesn't simply complete a loop and wait the next frame to restart it, but
calculates the correct time and starts a loop before the next frame if needed"
This was the answer I needed. Probably I should use a different aproach for
what I'm working.
By the way, thanks for answering so fast and for keeping HOTween update.
Original comment by marcos.c...@gmail.com
on 17 Dec 2012 at 7:48
Original issue reported on code.google.com by
marcos.c...@gmail.com
on 17 Dec 2012 at 6:38