I'm working on a first person shooter game.

My problem is that my Mouselook script is shaky and jittery when I looking around.

Here is my code:

Transform MyTransform;

const string vert_input = "Mouse Y";
const string horz_input = "Mouse X";

public float mouseSensitivity = 100.0f;
public float clampAngle = 80.0f;

void Update()
        the_time = Time.deltaTime;

        ROTX_ROTY.y += (Input.GetAxis(horz_input) * mouseSensitivity * current_speed_offset * the_time); 
        ROTX_ROTY.x += (Input.GetAxis(vert_input) * mouseSensitivity * current_speed_offset_vertical * the_time);

        ROTX_ROTY.x = Mathf.Clamp(ROTX_ROTY.x, -clampAngle, clampAngle);

        MyTransform.rotation = Quaternion.AngleAxis(ROTX_ROTY.y, Vector3.up);
        x_rot_transform.localRotation = Quaternion.AngleAxis(ROTX_ROTY.x, Vector3.left);

And this is my input settings for Mouse X and Mouse Y:

enter image description here

For more explanation: I put my camera inside one of my controller children and if I put it out of controller the issue is still there.

I tried Lerp, Slerp, smoothdamp , euler but does not make any difference.

I tried this script for Android and I used a touch instead of a mouse and the result was same.

I tried it on FixedUpdate and the result was same.

Is there any way to fix this problem?

Here is a video about my problem.

  • \$\begingroup\$ I'm unable to reproduce this problem with just the code shown here. Can you please edit your question to include a minimal complete verifiable example, including how you've configured the horz_input & vert_input controls in the Input Manager, and the values of / any code modifying the sensitivity and current speed offset parameters? \$\endgroup\$ – DMGregory Mar 28 '19 at 22:26
  • \$\begingroup\$ Try using FixedUpdate \$\endgroup\$ – Bálint Mar 29 '19 at 6:37
  • \$\begingroup\$ I tried ! but it's not working . @Bálint \$\endgroup\$ – iman_sh Mar 29 '19 at 9:56
  • \$\begingroup\$ What's the type of "the_time"? \$\endgroup\$ – Bálint Mar 29 '19 at 11:40
  • \$\begingroup\$ the_time is float !!! @Bálint \$\endgroup\$ – iman_sh Mar 29 '19 at 14:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.