As stated above, when I use time.deltatime in my first-person camera controller script, it makes the camera jitter very badly, but when I take it out, the camera works fine.
Of course, I want to keep time.deltatime in the script to avoid fps issues.
This problem only occurs on the new version of unity (2019.3.13f1). When I create a new project on older versions of unity and use the same script on a new object, the script works perfectly fine. It also works when I restart unity but if I edit the script, the camera starts to jitter again.
And this only seems to happen in the editor. When I build and run the game, the problem is gone.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class fpsController : MonoBehaviour
{
public Transform playerTF;
public Rigidbody playerRB;
public float sens = 5;
float xRotation = 0f;
private void Start()
{
Cursor.lockState = CursorLockMode.Locked;
}
private void FixedUpdate()
{
float mouseX = Input.GetAxis("Mouse X") * sens * Time.deltaTime;
float mouseY = Input.GetAxis("Mouse Y") * sens * Time.deltaTime;
xRotation -= mouseY;
xRotation = Mathf.Clamp(xRotation, -90f, 90f);
transform.localRotation = Quaternion.Euler(xRotation, 0, 0);
playerTF.Rotate(Vector3.up, mouseX);
}
}
Thanks in advance.