Installation

iTween can be used with all scripting languages that Unity supports including JavaScript, C# and Boo. To install iTween create a folder named "Plugins" in your project's assets (if you are using C# the location of iTween does not matter as long as it is inside your assets folder).

Hello World!

With iTween you can move, rotate, shake, punch, fade, scale, control audio, fade cameras and more! iTween is a static class which is a class that allows you to run methods on it, or call its properties, but never needs to be instantiated or created. As a user of iTween this means you never create a new instance of iTween; you simply ask it to do things for you.

In its simplest form you can ask iTween to animate with limited parameters allowing defaults to be filled in to save typing at the loss of customization. For example, to have iTween animate the position of something from its current position to a new position over the span of 2 seconds:

iTween.MoveTo(gameObject,Vector3(2,0,0),2);
				

iTween also offers the ability to create animations with full control over things such as delay, looping, callback functions and much more. To use iTween's more robust features you must provide the parameters you would like in the form of a Hashtable. There are a few different ways to approach this:

You can create Hashtables inline in JavaScript:

iTween.MoveTo(gameObject,{"x":3,"time":4,"delay":1,"onupdate","myUpdateFunction","looptype","pingpong"});				
				

You can construct and instantiate them in C# as you normally would:

Hashtable ht = new Hashtable();
	
void Awake(){
	ht.Add("x",3);
	ht.Add("time",4);
	ht.Add("delay",1);
	ht.Add("onupdate","myUpdateFunction");
	ht.Add("looptype",iTween.LoopType.pingPong);
}

void Start(){
	iTween.MoveTo(gameObject,ht);
}				
				

Or you can use iTween's Hash() method to make things consistent across all language and to allow calls to be done in 1 line in C#. The Hash() method requires alternating entries of a parameter name as a string followed by its value:

iTween.MoveTo(gameObject,iTween.Hash("x",3,"time",4,"delay",1,"onupdate","myUpdateFunction","looptype",iTween.LoopType.pingPong));				
				

iTween + PlayMaker = Awesome

The team over at Hutong Games have included iTween in their latest release (as of v 1.1) of their amazing visual scripting system called playMaker. You can grab their incredible tool here. You won't regret this purchase as it makes tasks that would have taken days to prototype possible within minutes.

iTween Visual Path Editor

I just released a visual path editor for use with iTween that allows easy motion path creation. You can take a look at it here.

iTween Visual Editor

David Koontz at Does Not Compute has finally released his truly awesome editor for approaching iTween through the friendly inspector that Unity uses. You can check out his release post here, a video showing how to use it here and you can visit the project's repository here.

iTween Parameter Code Hinting

Devin Reimer over at AlmostLogical.com has just released an outstanding helper for iTween to add parameter code hinting. Check it out!

Further Reading

I recently wrote an article for the Unity Creative magazine (issue #3 September-October 2010) which contains some more nitty-gritty information for getting up and running with iTween. Incidentally the issue my article is in also contains a write up from DoubleYou on their pinball game for Nike which extensively utilized iTween.

Purchase a copy of issue #3 to read more of my babbling about iTween as well as to help support a fantastic magazine singularly focused on helping empower and strengthen the Unity community.