Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Input Axis MouseX is not setup.

Discussion in 'Scripting' started by Aqubero, Jan 21, 2012.

  1. Aqubero

    Aqubero

    Joined:
    Jan 19, 2012
    Posts:
    8
    Why do i get this error??
    Code (csharp):
    1. UnityException: Input Axis MouseX is not setup.
    2.  To change the input settings use: Edit -> Project Settings -> Input
    3. MouseLook Pro.Update () (at Assets/MouseLook Pro.js:18)
    My Script:
    Code (csharp):
    1. var lookSensitivity : float = 5;
    2. @HideInInspector
    3. var yRotation : float;
    4. @HideInInspector
    5. var xRotation : float;
    6. @HideInInspector
    7. var currentYRotation : float;
    8. @HideInInspector
    9. var currentXRotation : float;
    10. @HideInInspector
    11. var yRotationV : float;
    12. @HideInInspector
    13. var xRotationV : float;
    14. var lookSmoothDamp : float = 0.1;
    15.  
    16. function Update ()
    17. {
    18.      yRotation += Input.GetAxis("MouseX") * lookSensitivity;
    19.      yRotation -= Input.GetAxis("MouseY") * lookSensitivity;
    20.      
    21.      xRotation = Mathf.Clamp(xRotation, -90, 90);
    22.      
    23.      currentXRotation = Mathf.SmoothDamp(currentXRotation, xRotation, xRotationV, lookSmoothDamp);
    24.      currentXRotation = Mathf.SmoothDamp(currentYRotation, yRotation, yRotationV, lookSmoothDamp);
    25.      
    26.      transform.rotation= Quaternion.Euler(currentXRotation, currentYRotation, 0);
    27. }
     
  2. Cameron860

    Cameron860

    Joined:
    Jun 1, 2009
    Posts:
    765
    Exactly what it says, there is no input called "MouseX".

    You probably want "Mouse X" or "Mouse Y" (the space is important).

    Do as the error says, look at Edit -> Project Settings -> Input

    This will show you all the currently defined inputs, and you can remove the space form the input name if you want.
     
  3. Matelotine

    Matelotine

    Joined:
    Apr 28, 2015
    Posts:
    1
    AAARRRRG. Thx
     
    SadjaK and Fajlworks like this.
  4. rabbitl

    rabbitl

    Joined:
    Dec 17, 2019
    Posts:
    1
    Hi. Anybody know why there is a error in my code. Thanks a lot if you could help.

    My code:

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;

    public class MouseLook : MonoBehaviour {

    public float mouseSensitivity = 100f;

    public Transform playerBody;

    float xRotation = 0f;

    // Start is called before the first frame update
    void Start()
    {
    Cursor.lockState = CursorLockMode.Locked;
    }

    // Update is called once per frame
    void Update()
    {
    float mouseX = Input.GetAxis("MouseX") * mouseSensitivity * Time.deltaTime;
    float mouseY = Input.GetAxis("MouseY") * mouseSensitivity * Time.deltaTime;

    xRotation -= mouseY;
    xRotation = Mathf.Clamp(xRotation, -90f, 90f);

    transform.localRotation = Quaternion.Euler(xRotation, 0f, 0f);
    playerBody.Rotate(Vector3.up * mouseX);
    }
    }
     
  5. TacticalDoggo

    TacticalDoggo

    Joined:
    Feb 17, 2020
    Posts:
    1
    I had the same problem here:

    float mouseX = Input.GetAxis("MouseX") * mouseSensitivity * Time.deltaTime;
    float mouseY = Input.GetAxis("MouseY") * mouseSensitivity * Time.deltaTime;

    you need spaces between ("Mouse X") and ("Mouse Y")
     
  6. ozimon

    ozimon

    Joined:
    Mar 19, 2020
    Posts:
    1
    hi can some one help me with this i don't know why i have error
    the code:
    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;

    public class mouselook : MonoBehaviour
    {

    public float mouseSensitivity = 100f;

    public Transform playerBody;


    // Start is called before the first frame update
    void Start()
    {

    }

    // Update is called once per frame
    void Update()
    {
    float mouseX = Input.GetAxis("Mouse X") * mouseSensitivity * Time.deltaTime;
    float mouseY = Input.GetAxis("mouse Y") * mouseSensitivity * Time.deltaTime;

    playerBody.Rotate(Vector3.up * mouseX);


    }
    }
     
  7. Aaditya_Chaturvedy

    Aaditya_Chaturvedy

    Joined:
    Jul 8, 2020
    Posts:
    1
     
unityunity