I've created a fairly simple mouse-look script for an fps game i'm working on, however I've noticed that while the mouse movement appears smooth, whenever I strafe around objects I get this annoying jittery look on objects that I focus on. Can someone take a look at my code, and tell me how I might improve it? Code (CSharp): public class PlayerLook : MonoBehaviour { public float mouseSensitivity = 100.0f; public float clampAngle = 80.0f; private float mouseX; private float mouseY; private float rotationX = 0.0f; private float rotationY = 0.0f; void Start() { Vector3 rotation = transform.localRotation.eulerAngles; rotationX = rotation.x; rotationY = rotation.y; } void Update() { mouseX = Input.GetAxis("Mouse X"); mouseY = Input.GetAxis("Mouse Y"); rotationX += mouseY * mouseSensitivity * Time.deltaTime; rotationY += mouseX * mouseSensitivity * Time.deltaTime; rotationX = Mathf.Clamp(rotationX, -clampAngle, clampAngle); Quaternion localRotation = Quaternion.Euler(rotationX, rotationY, 0.0f); transform.rotation = Quaternion.Lerp(transform.rotation, localRotation, Time.fixedTime); } }
I think I figured it out, my update functions on my rigidbody player and my mouse-look camera were different from each other. I changed them both to FixedUpdate and now it looks much smoother.