- Home /
 
               Question by 
               hballamco · Oct 02, 2020 at 08:21 AM · 
                rotationquaternioncamera rotateeulerdamping  
              
 
              rotation along the y-axis with damping not working!
So, I'm using this code to rotate the camera (attached to the player) along the x-axis and rotate the player body along the y-axis.
 public class MouseLook : MonoBehaviour
 {
     public float mouseSensitivity = 100f;
     public float rotationDamping = 5f;
 
     public Transform playerBody;
 
     float xRotation = 0f;
 
     // Start is called before the first frame update
     void Start()
     {
         Cursor.lockState = CursorLockMode.Locked;
     }
 
     // Update is called once per frame
     void Update()
     {
         float mouseX = Input.GetAxis("Mouse X") * mouseSensitivity * Time.deltaTime;
         float mouseY = Input.GetAxis("Mouse Y") * mouseSensitivity * Time.deltaTime;
 
         xRotation -= mouseY;
         xRotation = Mathf.Clamp(xRotation, -80f, 80f);
 
         Quaternion xRotationAngle = Quaternion.Euler(xRotation, 0f, 0f);
 
         transform.localRotation = Quaternion.Slerp(transform.localRotation, xRotationAngle, rotationDamping * Time.deltaTime);
         playerBody.rotation = Quaternion.Slerp(playerBody.rotation, Quaternion.Euler(0f, mouseX, 0f), rotationDamping * Time.deltaTime);
     }
 }
the x-axis rotation with damping is working just fine. yet, the y-axis rotation is not working at all. FYI, I used this before:
 playerBody.Rotate(Vector3.up * mouseX);
and it worked but I don't know how to implement the damping with it. thanks
               Comment
              
 
               
              Your answer
 
 
             Follow this Question
Related Questions
Quaternion snaps to a rotation when moving (and with input)? 1 Answer
Need help with storing Rotation in a Quaternion 1 Answer
How can I multiply the rotation of a mirrored object? 1 Answer
Pitch/yaw difference between 2 transforms 1 Answer
How do you manually override mecanim's interpolation with rotations? 2 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
               
 
			 
                