Input Axis MouseX is not setup.

Why do i get this error??

UnityException: Input Axis MouseX is not setup.
 To change the input settings use: Edit -> Project Settings -> Input
MouseLook Pro.Update () (at Assets/MouseLook Pro.js:18)

My Script:

var lookSensitivity : float = 5;
@HideInInspector
var yRotation : float;
@HideInInspector
var xRotation : float;
@HideInInspector
var currentYRotation : float;
@HideInInspector
var currentXRotation : float;
@HideInInspector
var yRotationV : float;
@HideInInspector
var xRotationV : float;
var lookSmoothDamp : float = 0.1;

function Update ()
{
	 yRotation += Input.GetAxis("MouseX") * lookSensitivity;
	 yRotation -= Input.GetAxis("MouseY") * lookSensitivity;
	 
	 xRotation = Mathf.Clamp(xRotation, -90, 90);
	 
	 currentXRotation = Mathf.SmoothDamp(currentXRotation, xRotation, xRotationV, lookSmoothDamp);
	 currentXRotation = Mathf.SmoothDamp(currentYRotation, yRotation, yRotationV, lookSmoothDamp);
	 
	 transform.rotation= Quaternion.Euler(currentXRotation, currentYRotation, 0);
}
1 Like

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.

13 Likes

AAARRRRG. Thx

2 Likes

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);
}
}

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”)

2 Likes

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);

}
}

2 Likes
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class MauseLook : MonoBehaviour
{
  
    public float mauseSensitivity = 100f;
    public Transform playerBody;

    void Start()
    {
       
    }

   
    void Update()
    {
        float mauseX = Input.GetAxis("Mause X") * mauseSensitivity * Time.deltaTime;
        float mauseY = Input.GetAxis("Mause Y") * mauseSensitivity * Time.deltaTime;

        playerBody.Rotate(Vector3.up * mauseX);
    }
}

this is my code and i put space between Mause and X/Y but i still have same error can some one help me ?

Mouse, not Mause

5 Likes

oh I did not notice this, thank you very much for your help

Problem Fixed here :

1 Like

Tanks you ahmedaniss for help me
Tanks

can someone say me why when i finished my code for looking aroun with a mouse when i move the mouse down it goes up and when i move the mouse up it goes down this is what i wrote from a video

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

public class MouseLook : MonoBehaviour {
[Tooltip(“The rotation acceleration, in degrees / second”)]
[SerializeField] private Vector2 acceleration;
[Tooltip(“A multiplier to the input. Describes the maximum speed in degrees / second. To flip vertical rotation, set Y to a negative value”)]
[SerializeField] private Vector2 sensitivity;
[Tooltip(“The period to wait untill resetting the input value. Set this as low as possible, without encountering stuttering”)]
[SerializeField] private float inputLagPeriod;

private Vector2 velocity; // The current rotation velocity, in degrees
private Vector2 rotation; // The current rotation, in degrees
private Vector2 lastInputEvent; // The last recived non-zero input value
private float inputLagTimer; // The time since the last received non-zero input value

private Vector2 GetInput() {
// Add to the lag timer
inputLagTimer += Time.deltaTime;
// Get the input vector. This can be changed to work with the new input system or even touch controls
Vector2 input = new Vector2(
Input.GetAxis(“Mouse X”),
Input.GetAxis(“Mouse Y”)
);

// Sometimes at fast franerates, Unity will not recieve input events every frame, which results
// in zero values being given above This can cause stuttering ad make it difficult to fine
// tune the acceleration setting. To fix this, disregard zero values. If the lag timer has passed the
// lag period, we can assume that the user is not giving any input, so we want to set
// the input value to zero at that time.
// thus, save the input value if it is non-zero or the lag timer is met
if ((Mathf.Approximately(0, input.x) && Mathf.Approximately(0, input.y)) == false || inputLagTimer >= inputLagPeriod) {
lastInputEvent = input;
inputLagTimer = 0;
}
return lastInputEvent;
}

private void Update() {
// The wanted velocity is the current input scaled by the sensitivity
// This is also the maximum velocity
Vector2 wantedVelocity = GetInput() * sensitivity;

// Calculate new rotation
velocity = new Vector2(
Mathf.MoveTowards(velocity.x, wantedVelocity.x, acceleration.x * Time.deltaTime),
Mathf.MoveTowards(velocity.y, wantedVelocity.y, acceleration.y * Time.deltaTime));
rotation += velocity * Time.deltaTime;

// Convert the rotation to euler angles
transform.localEulerAngles = new Vector3(rotation.y, rotation.x, 0);
}
}

i fixed it!!!

For the future, please create your own threads rather than hijacking existing ones because they have a title that sounds like your problem; they’re quick and free to create!

Finally, I would ask that when posting code, always use code-tags because as I’m sure you can see above, plain-text code on the forum is almost unreadable.

I am glad you resolved your issue. If it were your own thread I would ask that you make a quick note of how you fixed it for future users.

Good luck!

String comparisons are the worst for this exact reason “Mouse X” and “MouseX Tutuapp 9Apps Showbox” are not the same. USE “Mouse X”

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

public class CameraLook : MonoBehaviour
{

public float MouseSentisivility = 80f;

void Start()
{

}

void Update()
{

float MouseX = Input.GetAxis(“Mouse X”)*MouseSentisivility * Time.deltaTime;

float MouseY = Input.GetAxis(“Mouse Y”)*MouseSentisivility * Time.deltaTime;

}
}

I don’t know what it is, but I have had problems with this code, I have no idea what these line codes have.I don’t know how to program

Wow… let me offer you some simple steps to success:

Step 1: stop responding to 9-year-old threads

Step 2: Do LOTS of tutorials, and here is how to do tutorials properly:

Tutorials are a GREAT idea. Tutorials should be used this way:

Step 1. Follow the tutorial and do every single step of the tutorial 100% precisely the way it is shown. Even the slightest deviation (even a single character!) generally ends in disaster. That’s how software engineering works. Every single letter must be spelled, capitalized, punctuated and spaced (or not spaced) properly. Fortunately this is the easiest part to get right. Be a robot. Don’t make any mistakes. BE PERFECT IN EVERYTHING YOU DO HERE.

If you get any errors, learn how to read the error code and fix it. Google is your friend here. Do NOT continue until you fix the error. The error will probably be somewhere near the parenthesis numbers (line and character position) in the file. It is almost CERTAINLY your typo causing the error, so look again and fix it.

Step 2. Go back and work through every part of the tutorial again, and this time explain it to your doggie. See how I am doing that in my avatar picture? If you have no dog, explain it to your house plant. If you are unable to explain any part of it, STOP. DO NOT PROCEED. Now go learn how that part works. Read the documentation on the functions involved. Go back to the tutorial and try to figure out WHY they did that. This is the part that takes a LOT of time when you are new. It might take days or weeks to work through a single 5-minute tutorial. Stick with it. You will learn.

Step 2 is the part everybody seems to miss. Without Step 2 you are simply a code-typing monkey and outside of the specific tutorial you did, you will be completely lost.

Of course, all this presupposes no errors in the tutorial. For certain tutorial makers (like Unity, Brackeys, Imphenzia, Sebastian Lague) this is usually the case. For some other less-well-known content creators, this is less true. Read the comments on the video: did anyone have issues like you did? If there’s an error, you will NEVER be the first guy to find it.

Beyond that, Step 3, 4, 5 and 6 become easy because you already understand!

Finally, when you have errors…