iTween issue

Hi there, I have an iTween script, whic is attached to the Control Object, but running on ParentObject, so the hierarchy looks like this:

  • ControlObject
    • ParentObject
      • Subobject 1
      • Subobject 2

…and this is the code:

		 iTween.MoveTo (ParentObject, 
		 		iTween.Hash ("position", positionToMoveTo, "islocal", true, "delay", delayBeforeStart, "time", timeToMoveOut, "easetype", easeTypeOut, "oncomplete", "Return"));  

So all works well, the object is moved to the location I expect it to - the only problem is the function that ‘oncomplete’ calls is never executed. I’ve checked the itween script, it executes, then turns itself off once the object is at the target position, but for whatever reason, ‘Return’ is never called.

The only difference between this script and my previous usage of iTween (all of which worked perfectly, including oncomplete) is that the script is calling a different object than it’s attached to, to move. Can anyone help me out as to why Return isn’t getting called? Thanks in advance.

You need a “oncompletetarget” parameter(iTween for Unity by Bob Berkebile (pixelplacement)). Double check the documentation. So your code should look like this:

			iTween.MoveTo(ParentObject, iTween.Hash("position", positionToMoveTo, "islocal", true, "delay", delayBeforeStart, "time", timeToMoveOut, "easetype", easeTypeOut, "oncompletetarget", gameObject, "oncomplete", "Return"));		

gameObject refers to the gameObject that the script is attached to.