0

I have UI button that rotate an object in the scene when pressed with the MouseDown and stopes rotating when MouseUp.

I am rotating the object using the following code:

private float rotationSpeed = 205f;

public void dragBrain(GameObject brain) {
        float rotateX = Input.GetAxis("Mouse X") * rotationSpeed * Mathf.Deg2Rad;
        float rotateY = Input.GetAxis("Mouse Y") * rotationSpeed * Mathf.Deg2Rad;

        theObjectToRotate.transform.Rotate(Vector3.up, -rotateX);
        theObjectToRotate.transform.Rotate(Vector3.right, -rotateY);

    }

When I test the application with unity, it works fine (without VR), but when I build the project and test it on an Android device, the object doesn't rotate when I click the button.

Is it because I am trying to get the axis of the mouse? and its different with the VR?

And how should I go about doing it? because I tried to look for the documentations but with no luck.

sourceplaze
  • 333
  • 3
  • 11
  • On a mobile device you can not use the Mouse .. instead ou hae to use touch inputs. [See here](https://answers.unity.com/questions/805630/how-can-%C4%B1-rotate-camera-with-touch.html) and the [Unity Manual](https://docs.unity3d.com/Manual/MobileInput.html) – derHugo Sep 03 '18 at 05:42
  • @derHugo Thank you, i will take a look at it – sourceplaze Sep 03 '18 at 12:27
  • @derHugo Thank you it worked, could you please right an answer so that i can accept it – sourceplaze Sep 03 '18 at 19:05

0 Answers0