Giter VIP home page Giter VIP logo

Comments (2)

GoogleCodeExporter avatar GoogleCodeExporter commented on August 17, 2024
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 [email protected] on 17 Dec 2012 at 6:58

  • Changed state: Invalid

from hotween.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 17, 2024
"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 [email protected] on 17 Dec 2012 at 7:48

from hotween.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.