Camera not moving 'smoothly' on drag.

I wrote this script that responds to touch dragging on the right-hand side of the screen to move the player camera in the dragged direction. It works perfectly, except that the movement is quite jerky and not smooth, which would make it hard to aim at things. Is there a simple fix for this or am I doing it completely wrong?

var zSpeed = 2;
var ySpeed = 2;

function Update () {
	
	if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Moved) {
		
		var touch = Input.GetTouch(0);
		
		if (touch.position.x > Screen.width/2) {
		
			var player = GameObject.Find("Player");
        
	        // Get movement of the finger since last frame
	        var touchDeltaPosition:Vector2 = Input.GetTouch(0).deltaPosition;
	        
	        // Look up and down
	        transform.Rotate(-touchDeltaPosition.y * zSpeed, 0, 0);

            // Look left and right
	        player.transform.Rotate( 0, -touchDeltaPosition.x * -ySpeed, 0);	
		
		}
    
    }
	
}

Don’t ever use GameObject.Find() in Update, it will kill your performance. Do it in Start() and store the object.

The problem is that deltaPosition is not framebased. The touch sensor hardware has it’s own update interval which is most the time different from your visual framerate.

I use this extension method:

// C#
public static Vector2 FixedTouchDelta(this Touch aTouch)
{
    float dt = Time.deltaTime / aTouch.deltaTime;
    if (dt == 0 || float.IsNaN(dt) || float.IsInfinity(dt))
        dt = 1.0f;
    return aTouch.deltaPosition * dt;
}

It returns the true delta in pixels. Usually you should be able to use this extension method even in UnityScript by putting this method into a static C# class in the plugins folder.

Then you can use it like this:

touch.FixedTouchDelta()

instead of

touch.deltaPosition