UnityException: Input Axis Horizontal is not setup.

Hello, I’m doing the tutorial on making the “Roll-a-ball” game and I have just done the movement script for the ball but when I test the game the ball doesn’t move and this error shows in the console.

I have already checked the settings in Project Manager > Input > Horizontal and they look fine, what should I do?

2 Likes

Make sure it’s spelled exactly the same way in code as it is in the input manager.

–Eric

4 Likes

I’m an idiot, I missed the t off Horizontal :o thanks for the nudge

4 Likes

Yes, it’s very easy to misspell the string for Input.GetAxis(“”). And the error messages that result are very difficult for beginners to interpret.

Be nice if the code could be moved to the compiler instead of the interpreter. That’d alleviate a lot of these problems. For example, instead of

Input.GetAxis("Horizontal");

We did something like

Input.GetAxis(AxisInput.Horizontal);

which could be checked at compile instead of run-time. (Note that “Vertical” is a frequently misspelled word!)

1 Like

Given that this topic just got some likes, here’s a potentially useful necro…use a static class with constants:

public static class AxisInput {
    public const string Horizontal = "Horizontal";
    public const string Vertical = "Vertical";
}
Input.GetAxis(AxisInput.Horizontal);

You still have to spell strings correctly, but only once.

–Eric

im having this problem but cant identify the error ive copied and pasted the exact spelling unity has used for “horizontal” but the error persists

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

public class PlayerController : MonoBehaviour
{

public float speed = 5.0f;
public float turnspeed;
public float horizontalInput;
public float forwardInput;
// Start is called before the first frame update
void Awake()
{

}

// Update is called once per frame
void Update()
{
horizontalInput = Input.GetAxis(“horizontalInput”);
forwardInput = Input.GetAxis(“Vertical”);

// we’ll write code here
transform.Translate(Vector3.forward * Time.deltaTime * speed * forwardInput);
transform.Translate(Vector3.right * Time.deltaTime * turnspeed * horizontalInput);
}

problem fixed here :

me too bruh