iTween ValueTo interpolation ending with wrong value

Hello everyone.

I’m using ValueTo with a float.

My “from” value is 0 and my “to” value is 4.3 .

I used the function I’m calling from ValueTo to check what are the actual values that iTween is giving out.

The last 3 values where:

  • 4.3
  • 34.2
  • 65.3

So I end up with 65.3 as the value…

Any clues as to why this is happaning?

Anyone else encouterd this bug?

I reported this issue at iTween Project


Well, without your exact iTween parameters it would be harder to offer help. But, I can tell you this: From my iTween experience, I can say ValueTo is working as expected.

There are three reasons that may give you some weird values:

  1. The time of the tween is too short.
  2. And/or it takes iTween a bit longer than expected to start the tween (i.e. the infamous AddComponent hiccup).
  3. And/or you are using some more complex ease type (e.g. elastic, bounce, easeOutBack).

As you know, iTween adds a component to your object that is responsible for the tween. The first time it does that, you sometimes experience hiccups. If the tween is too short, then by the time it starts, it should already be at a higher value (nearing its end) so the update loop may be called only a few times - a couple of times with the values that are near the “from” value, and a couple of times with values near the “to”.

What you can do to remedy the situation?

  • Check if increasing the time of the tween helps
  • Check if adding a slight delay to the tween helps
  • Call iTween.Init( gameObject ) on your Awake() or Start()
  • If you have many objects that start executing iTween at the same time, you must Init them beforehand and even then, you may need to consider a different approach.

Finally, in your testing, eliminate any other variable, test first with a simple script, like this:

void Start() {
	iTween.Init( gameObject );
	iTween.ValueTo( gameObject, iTween.Hash(
		"delay"    , 1,
		"from"     , 0,
		"to"       , 4.9f,
		"time"     , 0.2f,
		"onUpdate" , "UpdateValue",
		"easeType" , iTween.EaseType.easeInOutBack

void UpdateValue( float val ) {