- Home /
 
 
               Question by 
               finlay_morrison · Jul 05, 2018 at 08:52 PM · 
                c#rotationrotateeulerangleseuler  
              
 
              Camera rotation behaving strangely
I have a script that should allow the player to look around, but there is some strange behaviour where the camera jumps back to looking forward every frame, i will link a video that shows the script for this and the behaviour of the camera.link text
               Comment
              
 
               
               
               Best Answer 
              
 
              Answer by Perfecter · Jul 05, 2018 at 09:47 PM
Hi. Seems you wanted to use euler angles instead of rotation. Try this:
 using UnityEngine;
 using UnityStandardAssets.CrossPlatformInput;
 
 public class CameraLook : MonoBehaviour
 {
     [SerializeField]
     private GhostPart ghostPart;
 
     [SerializeField]
     private float lookSensitivity = 10;
 
     private void Update()
     {
         FindCameraMovement();
     }
 
     private void FindCameraMovement()
     {
         if (!ghostPart.isGhostPartActive)
         {
             return;
         }
 
         float _xRot = CrossPlatformInputManager.GetAxis("Mouse X");
         float _yRot = CrossPlatformInputManager.GetAxis("Mouse Y");
         _yRot = -_yRot;
         Vector3 _rotation = new Vector3(_yRot, _xRot, 0) * Time.deltaTime * lookSensitivity;
         Vector3 _currentRotation = new Vector3(transform.eulerAngles.x, transform.eulerAngles.y, 0);
         Vector3 _newRotation = _rotation + _currentRotation;
         transform.rotation = Quaternion.Euler(_newRotation);
     }
 }
 
 
              Thanks so much @Perfecter that code runs perfectly
Answer by thepigeonfighter · Jul 05, 2018 at 09:19 PM
Try using transform.Rotate() instead. It's a pretty simple helper function. Let me know if it works.
Your answer
 
             Follow this Question
Related Questions
How to properly reference a Euler? 1 Answer
Rotating a model with increments 1 Answer
Rotation on Android vs. PC 0 Answers
Flip over an object (smooth transition) 3 Answers