Hi there,
I have created an grid of cubes

And I have the following script that rotates individual cubes when the mouse is pressed down and dragged across:
var rotationSpeed = 10.0;
var lerpSpeed = 2.0;
private var speed = new Vector3();
private var avgSpeed = new Vector3();
private var dragging = false;
private var targetSpeedX = new Vector3();
function OnMouseOver()
{
dragging = true;
}
function OnMouseExit()
{
dragging = false;
}
function Update ()
{
if (Input.GetMouseButton(0) && dragging) {
speed = new Vector3(-Input.GetAxis ("Mouse X"), Input.GetAxis("Mouse Y"), 0);
avgSpeed = Vector3.Lerp(avgSpeed,speed,Time.deltaTime * 5);
} else {
if (dragging) {
speed = avgSpeed;
dragging = false;
}
var i = Time.deltaTime * lerpSpeed;
speed = Vector3.Lerp( speed, Vector3.zero, i);
}
transform.Rotate(Vector3.forward, speed.x * rotationSpeed, Space.World);
}
However, once the cubes have finished rotating the end up something like this:

So my question is, whats the best method to use, so that when the cube finishes rotating it returns to it’s original position, i.e face up.
Thanks
As in it like snapping to position? or it will continue to rotate till it is in it's original position
– Eli-Davis