Rotating a Sphere... differences between editor and iOS

I’ve got a script that is component of a stationary sphere that is used to rotate the sphere by clicking and dragging:

var rotationSpeed = 10.0;
var lerpSpeed = 1.0;

private var speed = new Vector3();
private var avgSpeed = new Vector3();
private var dragging = false;
private var targetSpeedX = new Vector3();

function OnMouseDown() 
{
    dragging = true;
}

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( Camera.main.transform.up * speed.x * rotationSpeed, Space.World );
    transform.Rotate( Camera.main.transform.right * speed.y * rotationSpeed, Space.World );

}

When run in the Editor, it works as expected. The mouse can click on the sphere, and spin it at relatively 1:1. But when I run it on an iPad, two things go wrong:

  1. Whenever a finger touches the object, it “snaps” to some other position before rotating.

  2. The rotation is no longer at a ~1:1 movement, and the sphere moves very fast.

This is my first attempt at deploying to an iDevice. Can anyone tell me what is causing the difference in behavior?

1 Answer

1

Just to bookend this, the answer was to ignore the first frame of dragging once a mousedown has occurred. More info here.