- Home /
 
 
               Question by 
               nwott1 · May 08 at 10:15 PM · 
                inputbuildmousebug-perhaps  
              
 
              Mouse y-axis locked only in build
I have a mouse look script which allows the player to look up and down in a 3D first person game. It works perfectly in the Unity Editor. Once I build the game, I can only move the mouse on x-axis. I have tried using the old and new input system, but the same result happens. I have tried setting the window mode in the player settings to fullscreen and windowed already as well as setting the input system to both.
Here is a video clip of this happening: https://www.youtube.com/watch?v=_AxX2OmkU_Y
 public class MouseLook : MonoBehaviour
 {
     Transform playerTransform;
     PlayerController playerController;
     InputMaster input;
 
     Vector2 lookDir;
 
     public float sens = 500f;
 
     private float xRotation;
 
     // Start is called before the first frame update
     void Start()
     {
         // Hide cursor
         Cursor.lockState = CursorLockMode.Locked;
 
         playerTransform = transform.parent;
         playerController = playerTransform.GetComponent<PlayerController>();
         input = playerController.Input;
     }
 
     // Update is called once per frame
     void Update()
     {
         lookDir = input.Player.Look.ReadValue<Vector2>();
 
         // Gets mouse inputs
         float moveX = lookDir.x * sens * Time.deltaTime;
         float moveY = lookDir.y * sens * Time.deltaTime;
 
         // Clamps rotation
         xRotation -= moveY;
         xRotation = Mathf.Clamp(xRotation, -90f, 90f);
 
         transform.localRotation = Quaternion.Euler(xRotation, 0f, 0f);
         playerTransform.Rotate(Vector3.up * moveX);
     }
 }
 
              
               Comment
              
 
               
              Your answer
 
             Follow this Question
Related Questions
Distribute terrain in zones 3 Answers
Unity sometimes misses Mouse Button Release 1 Answer
issue with mouse input in windowed mode (Bug ?) 1 Answer