Simulating rotation-over-edge with iTween

Hello everyone,

I am very very new with Unity and I am trying to make a cube that moves like if it was rotated about one of its edges (simulating a torque). The best way I found so far to implement it perfectly was with iTween, but there is a problem. The first movement always runs perfectly, but in the following ones the cube rotates about a diferente axis. I know it has something to do with local and global coordinates systems, but i cant figure out how to solve it.

The cube has dimensions (1,1,1) and the Script to rotate it (almost) exactly by 1.0 in the z-direction is: (if I simply set up z= 1.0 it doesnt work, so I came up with this)

function Update () {

if (Input.GetKeyDown (KeyCode.UpArrow)){
iTween.moveAdd(gameObject, {"z":.78, "y":.78});
iTween.rotateTo(gameObject, {"x":90});
}

}

Anyone knows how to solve it?! Thanks a lot! =) P.S: I am using iTween 1.X (javaScript)

Judging by the lower cased functions you are using with iTween ("moveAdd" and "rotateTo") it appeards you are using iTween 1.0.XX. I would STRONGLY recommend you upgrade to 2.0.XX if you can.

This example works for 2.0 and should work with 1.0 as well it allows for rotation in all directions with the arrow keys:

var moving : boolean;
var time : float = .4;
var easetype : String = "easeinoutsine";
var moveAmnt : float = 1;
var rotAmnt : float = .25;

function Update () {
    if(Input.GetKey("up") && !moving){
        moving=true;
        iTween.MoveTo(gameObject, {"z":transform.position.z+moveAmnt,"oncomplete":"resetMoving","easetype":easetype,"time":time});
        iTween.RotateBy(gameObject, {"x":rotAmnt,"easetype":easetype,"time":time});
    }
    if(Input.GetKey("down") && !moving){
        moving=true;
        iTween.MoveTo(gameObject, {"z":transform.position.z-moveAmnt,"oncomplete":"resetMoving","easetype":easetype,"time":time});
        iTween.RotateBy(gameObject, {"x":-rotAmnt,"easetype":easetype,"time":time});
    }
    if(Input.GetKey("left") && !moving){
        moving=true;
        iTween.MoveTo(gameObject, {"x":transform.position.x-moveAmnt,"oncomplete":"resetMoving","easetype":easetype,"time":time});
        iTween.RotateBy(gameObject, {"z":rotAmnt,"easetype":easetype,"time":time});
    }
    if(Input.GetKey("right") && !moving){
        moving=true;
        iTween.MoveTo(gameObject, {"x":transform.position.x+moveAmnt,"oncomplete":"resetMoving","easetype":easetype,"time":time});
        iTween.RotateBy(gameObject, {"z":-rotAmnt,"easetype":easetype,"time":time});
    }
}

function resetMoving(){
    transform.eulerAngles=Vector3.zero;
    moving=false;
}

You can use iTween 2.0 with JavaScript OR C#. Take a look at the Getting Started page to help you get going! Also, all of the examples are written in both JS and C# if you want to take a look at them.