Camera self rotation script problem
Hello my problem is: I want to rotate my camera in length (from -> to) actually cursor location(from) -> length betwen cursor start position and position changing on click (to). I had problem with configure it because my camera is jumping and not moving smoothly. Second problem is that I want to rotate camera in length just from click not from the last position of cursor
The code is:
 // set up before scene start
     void Awake()
     {
         cameraDefault = Camera.main;
         standardCameraAnglesOfView();
         setCameraSmoothValue(0.1f);
     }
     // use this for initialization
     void Start()
     {
         this.isMouseActive = false;
         this.isCameraPositionZero = false;
         this.isCameraRotationZero = false;
         cameraPositionChecker();
         cameraRotationChecker();
     }
     // per frame
     void LateUpdate ()
     {
         getMouseAxisPerFrame();
         checkMouseStatus();
         onMouseHold();
     }
 // check if left mouse button is holded
     void checkMouseStatus()
     {
             if (Input.GetMouseButton(0))
             {
                 isMouseActive = true;
             }
             else
             {
                 isMouseActive = false;
             }      
     }
     // action used to be done while is holding left mouse button
     void onMouseHold()
     {
         if (isMouseActive)
         {
             if (currentMouseAxisX != onClickMouseAxisX && currentMouseAxisY != onClickMouseAxisY)
             {
                 getMouseAxisOnClick();
                 calculateMoveMouse();
                 cameraRotateAngles();
                 Debug.Log("pressed");
             }
         }
         else if (!isMouseActive)
         {
             //Debug.Log(" CX " + currentMouseAxisX + " CY " + currentMouseAxisY);
             Debug.Log("release");
         }
 
     }
     // get mouse axis every frame
     void getMouseAxisPerFrame()
     {
         this.currentMouseAxisX = Input.mousePosition.x;
         this.currentMouseAxisY = Input.mousePosition.y;
     }
     // get mouse axis to move
     void getMouseAxisOnClick()
     {
         this.onClickMouseAxisX = Input.mousePosition.x;
         this.onClickMouseAxisY = Input.mousePosition.y;
         //Debug.Log(" OX: " + onClickMouseAxisX + " OY: " + onClickMouseAxisY);
     }
     // get amount of move camera
     void calculateMoveMouse()
     {
         this.mouseMovementXLength = (onClickMouseAxisX - currentMouseAxisX * cameraSmoothWalue * Time.deltaTime);
         this.mouseMovementYLength = (currentMouseAxisY - onClickMouseAxisY) * cameraSmoothWalue * Time.deltaTime;
 
         this.mouseMovementYLength = Mathf.Clamp(mouseMovementYLength, minAngleY, maxAngleY);
         invertMouseMovementLenght();
         Debug.Log("LX " + mouseMovementXLength + " LY " + mouseMovementYLength);
     }
     // invert amount of camera move
     void invertMouseMovementLenght()
     {
        // this.mouseMovementXLength = -mouseMovementXLength;
         this.mouseMovementYLength = -mouseMovementYLength;
     }
     // set up camera smooth move
     public void setCameraSmoothValue(float smooth)
     {
         this.cameraSmoothWalue = smooth;
     }
     // camera rotate mechanic
     void cameraRotateAngles()
     {
         // change camera rotation on his own axis
         //cameraDefault.transform.rotation = Quaternion.Euler(mouseMovementYLength, mouseMovementXLength, 0 );
         cameraDefault.transform.Rotate(mouseMovementYLength, mouseMovementXLength, 0);
     }
Answer by GimpG1K · Aug 18, 2016 at 12:45 AM
Fixed by using another method of rotation you can check this out here: http://wiki.unity3d.com/index.php/SmoothMouseLook
Your answer
 
 
             Follow this Question
Related Questions
my camera is rotating on Z axis when i just set it on X and Y 0 Answers
How to have objects rotate around a given point that are scripted to face the player 1 Answer
Why won't my model rotate up on X axis? 1 Answer
Problems with rotation after zoom (camera like Sketchfab) 0 Answers
Problems with limiting angles 1 Answer
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                