Gamepad not working with Unity events, but working when accessed directly

I am having a weird problem trying to get my gamepad to work with the new Input System package 1.0.0 and Unity 2019.4.4f1.

I use the PlayerInput component method with the Behaviour set to Invoke Unity Events as per Input System Docs.

In the below code, OnMoveInput and OnJumpInput get called fine when the keyboard is used. When the gamepad is used however, they do not get called at all.

So you’d think the gamepad isn’t working. However, in the Update method, the gamepad works just fine when accessed directly!

Why does the gamepad work when accessed directly, but does not cause the Unity events to be fired off?

using UnityEngine;
using UnityEngine.InputSystem;

public class PlayerInputHandler : MonoBehaviour
{
    // Works with keyboard, but NOT with gamepad (Value)
    public void OnMoveInput(InputAction.CallbackContext context)
    {
        Debug.Log("Move (Action)");
    }
    // Also works with keyboard, but also NOT with gamepad (Button)
    public void OnJumpInput(InputAction.CallbackContext context)
    {
        Debug.Log("Jump (Action)");
    }

    // Works with gamepad!!!
    private void Update() {      
        if(Gamepad.current.aButton.wasPressedThisFrame) {
            Debug.Log("Jump (Update)");
        }
    }
}

What stands out in the following screenshots, is that nowhere do they mention Unity actually using my Gamepad control scheme???

Right, so I finally got it working. For anyone else who runs into this, the solution is as follows…

In my “Gamepad” Control Scheme, I had added two devices to the list (Wired and Wireless Gamepad). However, I hadn’t noticed that by default, under Requirements, both devices were set to Required. And that was the problem.

Switching both devices from Required to Optional solved it for me! Hooray!

6167321--674711--Screenshot 2020-08-04 at 13.04.26.png

1 Like

such a sneaky option, I had the same problem as you, thank you for posting the solution

1 Like