Search Unity

Question Camera stutters on build but not in editor

Discussion in 'Input System' started by LuigiNicastro, May 21, 2022.

  1. LuigiNicastro

    LuigiNicastro

    Joined:
    Feb 7, 2018
    Posts:
    34
    I've upgraded my project to the new input system and created a new camera look script from a tutorial I found. In my editor everything runs very well but once it's built the camera stutters whenever I look around. Anyone have an idea why?


    Code (CSharp):
    1. public class MouseLook : MonoBehaviour
    2. {
    3. #pragma warning disable 649
    4.  
    5.     public float sensitivityX = 1f;
    6.     public float sensitivityY = 0.5f;
    7.     float mouseX, mouseY;
    8.  
    9.     [SerializeField] Transform playerCamera;
    10.     [SerializeField] float xClamp = 85f;
    11.     float xRotation = 0f;
    12.  
    13.     private void Start()
    14.     {
    15.         Application.targetFrameRate = 300;
    16.         Cursor.lockState = CursorLockMode.Locked;
    17.         Cursor.visible = false;
    18.     }
    19.  
    20.     private void Update()
    21.     {
    22.         transform.Rotate(Vector3.up, mouseX * Time.deltaTime);
    23.  
    24.         xRotation -= mouseY;
    25.         xRotation = Mathf.Clamp(xRotation, -xClamp, xClamp);
    26.         Vector3 targetRotation = transform.eulerAngles;
    27.         targetRotation.x = xRotation;
    28.         playerCamera.eulerAngles = targetRotation;
    29.     }
    30.  
    31.     public void ReceiveInput(Vector2 mouseInput)
    32.     {
    33.         mouseX = mouseInput.x * sensitivityX;
    34.         mouseY = mouseInput.y * sensitivityY;
    35.     }
    36.  
    37. }
     
  2. LuigiNicastro

    LuigiNicastro

    Joined:
    Feb 7, 2018
    Posts:
    34
    I forgot to mention that the program runs well and smooth until I started moving the camera around. The camera look script I had on the old input system worked fine so It's something with the new input system I believe.