Search Unity

Rotating the camera to left or right using the scroll wheel

Discussion in 'Editor & General Support' started by Mathsunitt, Apr 18, 2014.

  1. Mathsunitt

    Mathsunitt

    Joined:
    Apr 13, 2014
    Posts:
    8
    Hello, I am trying to rotate my camera using the scroll wheel.
    What I'm saying is: The player press the mouse wheel and move to the left or to the right, so, the camera will rotate to the selected side.

    How can I do this?

    PS: The scroll wheel needs to be pressed to be able to spin.
     
  2. drewradley

    drewradley

    Joined:
    Sep 22, 2010
    Posts:
    3,063
    Do you have the code to rotate your camera already set up? If so, all you need to do is enclose it in:
    if (Input.GetMouseButton(2))
    {
    //rotation code goes here
    }
     
  3. Mathsunitt

    Mathsunitt

    Joined:
    Apr 13, 2014
    Posts:
    8
    I have the following code to left:

    Code (csharp):
    1. if (Input.GetMouseButton(2)  Input.GetAxis("Mouse X") < 0)
    2.         {
    3.             transform.Rotate(Vector3.up * 1.8f, Space.World);
    4.         }
    Do you know how to get a smooth rotation?