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);
}
}
}