Hey, I’m having troubles getting touch to work in WebGL.
In 5.2, touch did not work at all in WebGL, on Windows. It now works, but not correctly - It’s acting very strange.
I’ve built a WebPlayer version, and a WebGL version, of the program and they act very differently. The WebPlayer version acts exactly as predicted, and expected; while the WebGL version acts erratic and weird. The scene only contains a cube, that can be rotated by dragging your finger across the canvas.
WebPlayer version:
I drag my finger across the canvas, and the cube rotates, follwing my finger nicely. I lift my finger, and place it somewhere else - The cube does not move. I begin dragging from the new point, and the cube rotates again. All good.
WebGl version:
I place my finger on the Canvas, and the cube snaps to an akward diagonal angle and begins rotating on it’s own, while jittering slightly. I drag my finger across the canvas and the cube snaps to another orientation, then rotates, while jittering a lot. I release my finger and place it somewhere else, expecting nothign to happen. Instead the cube again snaps to a completely different orientation; and holding my finger on the canvas makes it rotate on it’s own. My best guess at the issue, was that DeltaPosition wasn’t getting reset correctly, but I’ve tried calculating DeltaPosition manually, with no change.
Any ideas? This is the code I use:
float rotationX = 0;
float rotationY = 0;
if (Input.touchCount == 1)
{
rotationX -= Input.GetTouch(0).deltaPosition.x * Time.deltaTime * 30f;
rotationY += Input.GetTouch(0).deltaPosition.y * Time.deltaTime * 30f;
cube.transform.eulerAngles = new Vector3(rotationY, rotationX, 0);
}
WebGL link: http://demo.cadpeople.com/cubetest/
WebPlayer link: http://demo.cadpeople.com/cubetest2/
Thanks for your time