Unity 3D: iTween animation

I was tasked to use iTween for Unity to create helicopter movement and rotor movement.


After looking through the iTween documentation which can be found here, I created a new scene and placed down a provided helicopter model and a camera, I then started to work on the script for the movement. After going over the documentation I worked with the hash table system as it seemed clearer to use when a few iTween movements where going to be used. But this ended up turning into long bits of code being repeated with minor changes all the way down:

This system also turned out to be jerky on each animation end due to easing types or relative speed on the animations being played after, aswell as being unable to control the speed of the propeller animation in a good way.


This script was scrapped and i started on a new script using callback feature on the iTween code, This Callback method runs a function when the animation ends. I am also breaking each bit of the script into the relative tasks here.


Task 1, Create a fixed point camera, at a high point to follow the helicopter at all times:

This one was an easy one, only requiring a few lines as shown,

Using Update void, That runs every frame, This code gets the current position of the helicopter and creates a vector3 (X,Y,Z coordinates) from it. This is then passed into the camera to set its position to this as-well, but offsetting it by 10 units on the Z axis to put it to the left and 4 units on the Y axis to set its position above the heli. The rotation was done in the editor so the script does not need to change it.


Task 2, start turning the rotor until achieves a cruising rotation speed:


I still chose to use a hashtable for this but instead, using callback on the method and clearing and resetting the hashtable with new values each time. First I started it off with a simple slow start,

To then increase the speed in such a way a heli would I real life, I chose to increase both the distance the animation rotates in the time given and decrease the time periodically, Like so.

This meant I had to then clear and set the hash table each run as well, I also changed the ease type from what the first animation takes to linear to try and give it a realistic speed up, not a slow speed up it took on the first.

Tasks 3-6:

  • once the cruising rotation speed achieved take off and lift the helicopter to a height of 5 units and at the same time rotating it 180 degrees

  • once the previous step finished move the helicopter in straight line for 20 units

  • when the previous step is concluded rotate the helicopter 180 degrees

  • when rotation finishes descend to the ground in 5 seconds

As these have to be done in order, I choose to do a callback on the same method again, but using an increasing int value on a Switch-case, Each one is done in hashtables once again.


Task 7, once you landed stop the rotation of the rotor:

This task involved would have had to be called upon the others ending, So this was done just by adding another case value into the switch above,

PropStart bool, was introduced to switch what mode the propeller would be doing each call. On false this simple flipped the if statements controlling the increase of time and rotation ammount in the exact same way.


after each task was done a few bits where changed to make sure it all goes together and runs fine, The end script looked like:



Scene Viewable here:

Press R to reset.

Leave a Reply

Your email address will not be published. Required fields are marked *

× 8 = sixteen