Question by 
               TheDogePwner · Jan 24, 2016 at 05:23 PM · 
                rotationtransformrotate  
              
 
              transform.Rotate rotating an axis it shouldn't be
Hello,
I am trying to make a camera that is rotatable by the user's mouse for an FPS game I'm making. The problem is, I always want to Z axis to be 0, but it still changes, even though it shouldn't be.
Here is my code:
     public Camera View;
 
     void Update () {
         View.transform.Rotate(new Vector3 (-Input.GetAxis ("Mouse Y"), Input.GetAxis("Mouse X"), 0f));
     }
And when I move my mouse around, the camera's Z axis still changes. (also, View is a child of the player. This script is added to the player.)
Thank you for your help!
               Comment
              
 
               
               
               Best Answer 
              
 
              Answer by OnikurYH · Jan 25, 2016 at 11:14 AM
Hi, you can force to set the eulerAngles z axis to 0 using transform.eulerAngles
     public Camera View;
 
     void Update ()
     {
         View.transform.Rotate(new Vector3 (-Input.GetAxis ("Mouse Y"), Input.GetAxis("Mouse X"), 0f));
         // Set enler angles z axis to 0 ----------------------------/
         View.transform.eulerAngles = new Vector3 (View.transform.eulerAngles.x, View.transform.eulerAngles.y, 0);
     }
Also, you can import the "Characters" Standard Assets for reference (MouseLook.cs) if want more features
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                