- Home /
Moving camera with mouse is choppy while moving with controller is smooth
I am seeing an extreme difference in the number of non-zero values generated by my InputActions when using a mouse vs using a controller. If I move the mouse non-stop for 5 seconds, I generate about 90 non-zero events. If I do the same with a controller, I generate about 500 non-zero events. I can't figure out why this is the case but it makes moving the camera with the mouse very difficult. Here is the code (it is being called in LateUpdate()):
private void CameraRotation()
{
Vector2 lookVector = _inputActions.Player.Look.ReadValue<Vector2>();
if (lookVector != Vector2.zero)
Debug.Log($"input: {lookVector}");
// if there is an input and camera position is not fixed
if (lookVector.sqrMagnitude >= _threshold && !LockCameraPosition)
{
_cinemachineTargetYaw += lookVector.x * Time.deltaTime;
_cinemachineTargetPitch += lookVector.y * Time.deltaTime;
}
// clamp our rotations so our values are limited 360 degrees
_cinemachineTargetYaw = ClampAngle(_cinemachineTargetYaw, float.MinValue, float.MaxValue);
_cinemachineTargetPitch = ClampAngle(_cinemachineTargetPitch, BottomClamp, TopClamp);
// Cinemachine will follow this target
CinemachineCameraTarget.transform.rotation = Quaternion.Euler(_cinemachineTargetPitch + CameraAngleOverride, _cinemachineTargetYaw, 0.0f);
}
And here is the pertinent action in my Input Action:
Your answer
Follow this Question
Related Questions
Projection to mouse position in isometric game 1 Answer
Input: Missing mouse button events 2 Answers
How to get GameObject that is clicked by a mouse? 2 Answers
How to detect number of mouse/trackpad buttons? 0 Answers
Input.GetKeyDown, Input.GetKeyUp, and mouse wheel do not work while playing in the editor. 0 Answers