Hi guys
I have an app I'm building in Unity with Vuforia for Android. (have posted this in Unity also) I've succesfully got the object rotating when i click and drag, and it works on the computer. It also works on the phone, however, when I tap the object it seems to reset the position of the object. It's hard to describe but basically it's like it keeps bringing the object back to the starting point. This isn't happening on the computer. Heres the code:
<pre class="brush: jscript">
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 ); }
</pre>
Can you see something I'm missing or that would be causing the object to rotate smoothly on computer but constantly snap back to starting point on phone?
Regards
Sam
Touch/Drag To Rotate Resetting Object Locatio
Please avoid creating 2 threads on the same topic/question:
https://developer.vuforia.com/forum/unity-3-extension-technical-discussion/touchdrag-rotate-resetting-object-location
Thanks.