Search Unity

How to limit transform.Rotate(float,0,0)?

Discussion in 'Scripting' started by Tomza, Feb 17, 2019.

  1. Tomza

    Tomza

    Joined:
    Aug 27, 2013
    Posts:
    596
    Hi,



    I know that there are some answers in Google, but I cannot limit the rotation with the code:



    pitch = cameraDirectionSpeed * Input.GetAxis("Mouse Y");

    cameraPivot.transform.Rotate(-pitch, 0, 0, Space.Self);



    I wish to have limits from 0 to 90 on the x axis.



    Thank you!
     
  2. EasyUI

    EasyUI

    Joined:
    May 8, 2016
    Posts:
    10