Question by 
               The_RocketMan · Aug 02, 2016 at 08:20 PM · 
                camerabugmobilecamera rotateaccelerometer  
              
 
              Limit Z axis rotation on main camera (BUG?)
Working on mobile tilt controlled game, having a lot of issues making the accelerator controls feel 1 to 1 to my phone movement. So I decided to make the game control better by limiting exactly how much the player can rotate the camera (game world).
THE PROBLEM : the camera correctly stops when the Z axis is 35 however, whenever the Z axis reaches 0 it instantly jumps to Z 35f again. This is a problem because I would like to limit the camera at Z 35 and -35.
     public float viewRange = 35f;
     
     // Update is called once per frame
     void Update () {
         Debug.Log(Camera.main.transform.localEulerAngles.z);
         if (Camera.main.transform.localEulerAngles.z > viewRange)
         {
             Camera.main.transform.localEulerAngles = new Vector3(0, 0, viewRange);
         }
       /* else
         {
             if (Camera.main.transform.localEulerAngles.z < -viewRange)
             {
                 Camera.main.transform.localEulerAngles = new Vector3(0, 0, -viewRange);
             }
         }
         */
 
         float temp = Input.acceleration.x;
         transform.Rotate(0, 0, -Input.acceleration.x);
 
               (commented the else section because I was trying to locate the issue, also huge amateur)
               Comment
              
 
               
              Your answer
 
             Follow this Question
Related Questions
I need help witha bug,Glitch While looking up 0 Answers
Why does my transform.lookat not work? 1 Answer
Fixed Camera rotate to follow player 2 Answers