I'm working on a simple AR Vuforia application. How can I implement the rotation of an object along all three axes with one finger swipe?
The code I'm currently using has one bug: the rotation of the object depends on its local axes. For example, if I look at the object from the front, everything works as it should, but if I look at the object from the back side, the finger swipe upwards makes it rotate downwards and vice versa.
Here is this script:
public float rotSpeed = 30f;
void OnMouseDrag()
{
float rotX = Input.GetAxis("Mouse X")*rotSpeed*Mathf.Deg2Rad;
float rotY = Input.GetAxis("Mouse Y")*rotSpeed*Mathf.Deg2Rad;
transform.Rotate(Vector3.up, -rotX);
transform.Rotate(Vector3.right, -rotY);
}
But this is not what I need, how can I rotate the object according to the finger swipe direction regardless of the angle from which I look at it?
Hi @isamalhassan,
As mentioned by medabit, in our Core Sample app available on the Unity asset store, there is scene Ground Plane in which we demo exactly this behaviour.
Link to our Core Sample app: https://assetstore.unity.com/packages/templates/packs/vuforia-core-samples-99026
Thank you.
Vuforia Engine Support