Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Can't get current control scheme

Discussion in 'Input System' started by Lefko, Jul 1, 2022.

  1. Lefko

    Lefko

    Joined:
    Jan 5, 2020
    Posts:
    18
    In the new Input System, I am trying to get the current control scheme, to tell whether the player is using a keyboard/mouse or a gamepad. I've tried several different ways, but all return null:

    Debug.Log(playerInput.currentControlScheme);

    and
    if (playerInput.GetDevice<Gamepad>() != null) { Debug.Log("Player is using Gamepad"); }

    and
    playerActionMap = playerInput.actions.FindActionMap("Player");

    In the first two examples, playerInput is a type of PlayerInput. In the third example, playerActionMap is a type of InputActionMap. In my input action, I have Gamepad and Keyboard control schemes. I still get null even when I set the default input to keyboard in the PlayerInput in the inspector. I'm missing something obvious...
     
  2. Lefko

    Lefko

    Joined:
    Jan 5, 2020
    Posts:
    18
    I figured out the problem. I had several PlayerInputs in my scene, one attached to my player, and two more attached to cameras. Once I deleted the ones attached to my cameras, everything started working.