- Home /
 
               Question by 
               Abraham1532002 · Aug 17, 2017 at 08:09 PM · 
                c#camerarotationscript.rotation axis  
              
 
              How to rotate mouse addresses?
Hi.
My problem is that I need to be able to rotate my character about 180 degrees, but I have a problem since the character is broken, but the camera does not rotate because it has a rotation script with the mouse and now I think I need to rotate the mouse .
My original code of rotation with the mouse:
 void Update(){
         currentRotation.x += Input.GetAxis("Mouse X") * sensitivity;
     currentRotation.y -= Input.GetAxis("Mouse Y") * sensitivity;
    //The maximum angle is 50 degrees    
    currentRotation.x = Mathf.Clamp(currentRotation.x, -maxYAngle, 
    maxYAngle/*360*/);
     currentRotation.y = Mathf.Clamp(currentRotation.y, -maxYAngle, maxYAngle);
     transform.rotation = Quaternion.Euler(currentRotation.y,currentRotation.x,0);
     if (Input.GetMouseButtonDown(0))
         Cursor.lockState = CursorLockMode.Locked;
 
 
 }
What I try to do is directly rotate the camera 180 degrees, but it did not work:
 public float smooth = 1f;
 
 private Vector3 targetAngles; 
 
 void Update(){
  if(Input.GetKeyDown(KeyCode.S)) 
         targetAngles = transform.eulerAngles + 180f * Vector3.up; 
 
     transform.eulerAngles = Vector3.Lerp(transform.eulerAngles,targetAngles, smooth * Time.deltaTime);         
 
 
 currentRotation.x += Input.GetAxis("Mouse X") * sensitivity;
      currentRotation.y -= Input.GetAxis("Mouse Y") * sensitivity;
     //The maximum angle is 50 degrees    
     currentRotation.x = Mathf.Clamp(currentRotation.x, -maxYAngle, 
     maxYAngle/*360*/);
      currentRotation.y = Mathf.Clamp(currentRotation.y, -maxYAngle, maxYAngle);
      transform.rotation = Quaternion.Euler(currentRotation.y,currentRotation.x,0);
      if (Input.GetMouseButtonDown(0))
          Cursor.lockState = CursorLockMode.Locked;
  
  
  }
Forgive my English and thank you
               Comment
              
 
               
              Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                