0

My camera rotates whenever I rotate it, I am not sure why, I have tried many solutions including: multiplying by time.deltatime, dividing by time.deltatime, trying all variations of update void, I also tried to get mathf.smoothdampenangle to work but I couldn't figure out how to make the float change to a quaternion. I have set interpolation to interpolate.

Here is my code for my FPS characters camera:

{

// Variables
public Transform player;
public Transform rotatePoint;
public float mouseSensitivity = 2f;
float cameraVerticalRotation = 0f;
float velocity = 1f;

//bools
bool lockedCursor = true;

void Start()
{
    // Lock and Hide the Cursor
    Cursor.visible = false;
    Cursor.lockState = CursorLockMode.Locked;
}


void FixedUpdate()
{
    
    // Collect Mouse Input

    float inputX = Input.GetAxisRaw("Mouse X") * mouseSensitivity;
    float inputY = Input.GetAxisRaw("Mouse Y") * mouseSensitivity;

    // Rotate the Camera around its local X axis

    cameraVerticalRotation -= inputY;
    cameraVerticalRotation = Mathf.Clamp(cameraVerticalRotation, -90f, 90f);
    transform.localEulerAngles = Vector3.right * cameraVerticalRotation;
    // Rotate the Player Object and the Camera around its Y axis
    player.Rotate(Vector3.up * inputX);
}

}

I suspect the cause for the jitter is that my camera is rotating in set amounts of degrees instead of rotating smoothly.

1
  • Is there a reason why you use FixedUpdate for this? Are there other things moving the camera? Commented Jan 31 at 15:53

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.