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???