Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Game Development How to Make a Video Game Player Input and Cameras Move the Player with Animation

Arman Arutyunov
Arman Arutyunov
21,900 Points

Error. ArgumentException: Input Axis Horizantal is not setup.

I've received an error: ArgumentException: Input Axis Horizantal is not setup. To change the input settings use: Edit -> Project Settings -> Input PlayerMovement.Update () (at Assets/Scripts/PlayerMovement.cs:18)

Have no idea why because I retyped everything pretty accurately in code like hundred times! Maybe anyone could find a mistake?

using UnityEngine;
using System.Collections;

public class PlayerMovement : MonoBehaviour {

    private Animator playerAnimator;
    private float moveHorizontal;
    private float moveVertical;
    private Vector3 movement;

    // Use this for initialization
    void Start () {
        playerAnimator = GetComponent<Animator> ();
    }

    // Update is called once per frame
    void Update () {
        moveHorizontal = Input.GetAxisRaw ("Horizontal");
        moveVertical = Input.GetAxisRaw ("Vertical");

        movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
    }

    void FixedUpdate () {
        if (movement != Vector3.zero) {
            playerAnimator.SetFloat ("Speed", 3f);
        } else {
            playerAnimator.SetFloat ("Speed", 0f);
        }
    }
}
Manuel Uribe
Manuel Uribe
6,249 Points

If you see the following compile error, or a similar one, then you have a spelling mistake in your code.

ArgumentException: Input Axis Horizantal is not setup. To change the input settings use: Edit -> Project Settings -> Input PlayerMovement.Update () (at Assets/Scripts/PlayerMovement.cs:18)

In the case above, Horiz a ntal should be Horiz o ntal. The following code has replaced "Horizantal", with the incorrect 'a', with the correct spelling, "Horizontal".

        moveHorizontal = Input.GetAxisRaw ("Horizontal");

I made the same mistake when I first ran the code. Thanks for posting this question.

1 Answer

Alan Mattanรณ
PLUS
Alan Mattanรณ
Courses Plus Student 12,188 Points

Hi Arman, [I'm learning english, my english is not good] Double click the error and the Mono or Visual Studio editor will open showing you the position with the cursor in where is the error (close to the error). probably it will select the line where is the error. If it is

          moveHorizontal = Input.GetAxisRaw ("Horizontal");

since moveVertical and Input.GetAxisRaw do not has a red line under it so probably are correct. There is also a correct line ending (""); probably "Horizontal" is not declare in the Input system or was change.

So double check the Input setup by selecting in the unity toolbar, Edit -> project Settings -> Input and in the Inspector you will find Axes. Expand the list. Here you find all the inputs Name and in this case must be Horizontal (is upper case sensitive).

Sometimes this settings can change when you import assets that change them. More in detail the file containing this list is in the folder "ProjectSettings". There is the file InputManager.asset . If you change this file, it will change all the input settings. When you import an asset that change the files in "ProjectSettings", unity will let you know.

Hope this answer is close to your question. If is not, look if the 'Animator' is attached to the game object.