GetAxis Horizontal always returns 0

The code: Debug.Log("XZ: " + Input.GetAxis("Horizontal"));
No matter how much I press A or D it just doesn’t budge XZ: 0

This used to work, until it stopped and I started investigating to find out that GetAxis("Horizontal") always returns 0. Here’s a screenshot from Input Manager.

Regardless whether I press either A or D it just keeps stacking 0’s in the console.

Edit: The Debug.Log is in Update function.

You might check your Standalone Input Module (one of the game objects Unity creates for you automatically) to verify that it’s enabled and doesn’t have any wacky settings.

Other fast check steps:

  • try another Axis… does Vertical work? What about Fire? Others??

  • make a new project, pull up its Input Manager window. Do the numbers look different? If so, overwrite the InputManager in your project with that one, assuming you haven’t customized it heavily.

ALSO: always use source control so you can detect unintentional changes to a file like InputManager.asset, which shouldn’t normally change unless you intend it to by actually performing input configuration work, which should be a relatively rare operation.

ALSO: try perhaps a reimport all, in case something is borkled.

Its enabled, its been reset and its Force Enable Module = true.

            // Doesn't work
            Debug.Log("Vert: " + Input.GetAxis("Vertical"));
           
            // Works
            if (Input.GetKey(KeyCode.Mouse0)) Debug.Log("KeyCode.Mouse0 On");
            else Debug.Log("KeyCode.Mouse0 Off");
           
            // Works
            if (Input.GetKey(KeyCode.A)) Debug.Log("KeyCode.A On");
            else Debug.Log("KeyCode.A Off");
           
            // Doesn't work
            if (Input.GetAxis("Fire1") != 0) Debug.Log("Fire1 On");
            else Debug.Log("Fire1 off");

and

// Does work
GameObject.Find("XXXX").GetComponent<Button>().onClick.AddListener(() => Debug.Log("Left click hello?"));

Whatever is going on its related to GetAxis().

I opened a new project, exported the settings and imported them into this project, no changes, I don’t believe I’ve even ever opened Input Manager in this project, standard keys are fine to me.

Too complicated for me.

I did that, nothing has changed.

Try creating an entirely new, blank Unity project, copy in ONLY your test script, and see if it works there.

If it works in a new project, that will tell us it’s somehow related to your project configuration. If it still doesn’t work, then it’s either a problem with your test script or with your Unity install, and you should post the entire test script here.

Yes.

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

public class SWIPT : MonoBehaviour
{
    void Update()
    {
        Debug.Log($"yep: {Input.GetAxis("Horizontal")}");
    }
}

Works in an empty project, doesn’t work in my project. Is there a reset option for UI just like for everything else?

Not entirely sure what you mean by “reset for UI”, but you can force Unity to re-generate various settings from scratch by deleting the corresponding files from your ProjectSettings folder. (You may want to make a backup first.)