Ok Guys, I tried everything but again it doesn't work as expected so I hope in your help. I'll attach the script which rotates an object as soon as the mouse is down. I adapted it to the Touch of the IPhone/Pad. For non-iOS applications, it works very well (of course no augmented reality), but as soon as I use the script attached to an object within the project of Augented reality the object rotates in the most weird ways. ARCamera WorldCenterMode was set on NONE and AUTO. So I beg your help ! :) see below:
var numberAverages : int = 3; private var originalRotation : Quaternion; private var offsetRotation : Quaternion; // Make sure there is always a Rigidbody @script RequireComponent (Rigidbody) @script RequireComponent (SphereCollider) function Awake () { numberAverages = Mathf.Clamp (numberAverages, 1, numberAverages); } function OnTouchDown () { var hit : RaycastHit; var dir : Vector3; // Stop spinning rigidbody.angularVelocity = Vector3.zero; // Record initial variables if (Physics.Raycast (camera.main.ScreenPointToRay(Input.mousePosition), hit)) { originalRotation = transform.localRotation;//rotation; dir = hit.point - transform.position; offsetRotation = Quaternion.Inverse (Quaternion.LookRotation (dir)); Spin (dir); } } function Update() { if (Input.touchCount > 0) { if (Input.GetTouch(0).phase == TouchPhase.Began || Input.GetTouch(0).phase == TouchPhase.Moved) OnTouchDown(); } } function Spin (dir : Vector3) { var hit : RaycastHit; var previousDirList : Array = new Array (); //var previousDirList: Vector3[]; var currentDir : Vector3; // Initialize previous dir list for (var i : int = 0; i < numberAverages; i++) { previousDirList.Add (currentDir); // previousDirList.Push(currentDir); } currentDir = dir; // Make the object rotate with the cursor while we are grabbing it while (Input.GetButton ("Fire1") && Physics.Raycast (camera.main.ScreenPointToRay(Input.mousePosition), hit)) { // Remove first element of the array previousDirList.RemoveAt (0); // Add current dir to the end previousDirList.Add (currentDir); currentDir = hit.point - transform.localPosition;//position; transform.localRotation = Quaternion.LookRotation (currentDir) * offsetRotation * originalRotation;//rotation = yield; } // User let go of the mouse so make the object spin on its own var avgPreviousDir : Vector3 = Vector3.zero; for (dir in previousDirList) { var tmpDir: Vector3 = dir; avgPreviousDir = avgPreviousDir + tmpDir; } avgPreviousDir /= numberAverages; //Kick (currentDir, avgPreviousDir); }
This is not a Vuforia issue.
You may have more luck searching over at the Unity forums or doing a web search as this has most likely come up before.
N