Smooth Rotate with transform.Rotate?

Ok I made this script for iphone swipe to look controls, but right now it jumps between the different rotations, how would I go about making it rotate smoothly?

var aPosX;
var bPosX;
var moveMag;
var moveSpeed : float = 2;
var moveInit : float = 10;

function Update () {
for (var i=0; i < iPhoneInput.touchCount; i++){
var touch : iPhoneTouch = iPhoneInput.touches[i];
if(touch.phase == iPhoneTouchPhase.Began){
aPosX = touch.position.x;
}
if(touch.phase == iPhoneTouchPhase.Moved){
bPosX = touch.position.x;
moveMag = (bPosX - aPosX)/moveSpeed;
moveMag = 0 - moveMag;
transform.Rotate(0, moveMag, 0);
}
if(touch.phase == iPhoneTouchPhase.Ended){
moveMag = 0;
}
}
Debug.Log(moveMag);
}

OK, I tinkered with your script… alot actually. since I dont have an iphone, or unity pro… I translated it to just using a mouse. and here is what I got:

var aPosX;
var bPosX;
var moveMag=0.0;
var moveSpeed : float = 2.0;

function Update () {
	//for (var i=0; i < iPhoneInput.touchCount; i++){
		//var touch : iPhoneTouch = iPhoneInput.touches[i];
		//if(touch.phase == iPhoneTouchPhase.Began){
		if (Input.GetMouseButtonDown(0)) {
			//aPosX = touch.position.x;
			aPosX = Input.mousePosition.x;
		}
		//if(touch.phase == iPhoneTouchPhase.Moved){
		if(Input.GetMouseButton(0)){
			//bPosX = touch.position.x;
			bPosX = Input.mousePosition.x;
		}
		//if(touch.phase == iPhoneTouchPhase.Ended){
		if(Input.GetMouseButtonUp(0)){
			aPosX=bPosX;
		}
		if(aPosX!=bPosX){
			moveMag = (bPosX - aPosX)/moveSpeed;
		}else{
			moveMag = moveMag * 0.9;
		}
		transform.Rotate(0, -moveMag, 0);
		aPosX=bPosX;
	//}
}

First, I changed the move magnitude to always be equal to the difference in the last x position, vs the current x position. Doing this gives me an increment, rather than an addition from the original touch location and the current. (I think this would solve your problem as it is)

Next I added a little logic to continue the movement a little when you let up, or stop moving your finger/mouse.

Lastly, I removed the dependency of the moveMag in your touch, at let it roam freely. This means it wouldn’t stop immediately.

I am sure that you can translate the changes a bit. I have zip experience with the touch controls, so I commented them all out.

Thanks a lot for the help, I’ll try out your code as soon as I can and post back here with the results.

Heh, and a little more tweaking and I got it to auto rotate, let you change the rotation and then return back to the auto rotation after a little while.

var aPosX;
var bPosX;
var moveSpeed : float = 2.0;
private var stopTime=0.0;
private var moveMag=1.0;

function Update () {
	//for (var i=0; i < iPhoneInput.touchCount; i++){
		//var touch : iPhoneTouch = iPhoneInput.touches[i];
		//if(touch.phase == iPhoneTouchPhase.Began){
		if (Input.GetMouseButtonDown(0)) {
			//aPosX = touch.position.x;
			aPosX = Input.mousePosition.x;
		}
		//if(touch.phase == iPhoneTouchPhase.Moved){
		if(Input.GetMouseButton(0)){
			//bPosX = touch.position.x;
			bPosX = Input.mousePosition.x;
		}
		//if(touch.phase == iPhoneTouchPhase.Ended){
		if(Input.GetMouseButtonUp(0)){
			aPosX=bPosX;
		}
		if(aPosX!=bPosX){
			stopTime=Time.time;
			moveMag = (bPosX - aPosX)/moveSpeed;
		}else{
			moveMag = Mathf.Lerp(moveMag * 0.95, 1, (Time.time-stopTime) * 0.1);
		}
		//moveMag=1;
		transform.Rotate(0, -moveMag, 0);
		aPosX=bPosX;
	//}
}

Incorporate this bit of code into your script as needed:

var damp : float = 5;

function Update(){

        var target = Vector3(0, 0, 0);
    var rotate = Quaternion.LookRotation(target - transform.position);
    transform.rotation = Quaternion.Slerp(transform.rotation, rotate, Time.deltaTime * damp);

}

Also check out this tutorial video at [mod edit : old link removed]
The site has a bunch of great tutorials. Check them out too if you want!