- Home /
 
               Question by 
               vuqarahim · Mar 15, 2021 at 03:37 AM · 
                c#rotationquaternioncamera rotatetouch controls  
              
 
              Weird shake when I try to rotate player according to Virtual Cameras rotation.
so Im trying to do some cool stuff with cinemachine for the first time, and Im making an mobile fps game, but when I try to rotate players body according to virtual camera's rotation it does this weird shaking effect:
(I put the camera's follow target behind the player just to show the shake)
Here is the script Im taking the virtual cameras rotation. this is a extension script for overriding input values of virtual camera:
       protected override void PostPipelineStageCallback(CinemachineVirtualCameraBase vcam, CinemachineCore.Stage stage, ref CameraState state, float delta)
 {
     if (vcam.Follow)
     {
         if (stage == CinemachineCore.Stage.Aim)
         {
             if (startingRotation == null) startingRotation = transform.localRotation.eulerAngles;
             Vector2 deltaInput = aim.lookInput;
             startingRotation.x += deltaInput.x * horizontalSpeed * Time.deltaTime;
            
             state.RawOrientation = Quaternion.Euler(transform.localRotation.eulerAngles.y, startingRotation.x, 0);
             rotation = state.RawOrientation;
         }
     }
 }
and here Im using it to rotate player:
 void Rotate()
 {
     Quaternion rot = pOVExtension.rotation;
     rot.x = transform.rotation.x;
     rot.z = transform.rotation.z;
     float rotateSpeed;
     rotateSpeed = 20;
     Quaternion lookDir = rot;
     Quaternion targetRot = Quaternion.Slerp(transform.rotation, lookDir, rotateSpeed * Time.deltaTime);
     if (shotCamera.m_Priority < 10)
         transform.rotation = targetRot;
 }
Im only rotating on y axis. I move the character with rigid.velocity but its doesnt shake when moving, but only when rotating.
any help is appreciated. Thanks in advance
               Comment
              
 
               
              Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                