I'm trying to make first person movement with the new Input System and I'm noticing weird stuttering while moving the camera, it's a lot more noticable on lower sensitivities and pretty annoying. How can I fix this?
using UnityEngine;
public class MouseLook : MonoBehaviour {
public Transform playerBody;
[Range(1f, 100f)]
public float mouseSensitivity = 10f;
private InputMaster controls;
private Vector2 mouseLook;
private float xRotation;
private void Awake() {
controls = new InputMaster();
Cursor.lockState = CursorLockMode.Locked;
}
private void Update() {
Look();
}
private void Look() {
mouseLook = controls.Player.Look.ReadValue<Vector2>();
var mouseX = mouseLook.x * mouseSensitivity * Time.deltaTime;
var mouseY = mouseLook.y * mouseSensitivity * Time.deltaTime;
xRotation -= mouseY;
xRotation = Mathf.Clamp(xRotation, -90f, 90f);
transform.localRotation = Quaternion.Euler(xRotation, 0, 0);
playerBody.Rotate(Vector3.up * mouseX);
}
private void OnEnable() {
controls.Enable();
}
private void OnDisable() {
controls.Disable();
}
}