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

PlayerInput Component not working with control schemes.

Discussion in 'Input System' started by viatech, Dec 16, 2019.

  1. viatech

    viatech

    Joined:
    Dec 6, 2017
    Posts:
    55
    Thought I would try out the PlayerInput component.....

    I have an example project using two players each with a PlayerInput component. If no control schemes are used in the InputActionAsset then devices (KB and Gamepad) bind to actions as expected (Keyboard to KB and XBox controller to Gamepad), but obviously you can't tell player1 input from player2. Fire is the Enter key or the RT trigger and produces a Debug.Log message.

    If you specify a Gamepad control scheme and then a KB control scheme in the InputActionAsset and bind one player to the Gamepad and one to the keyboard then, on play there is no binding between actions and devices, so you get no input at all. What I expected was one player using Gamepad input and one using KB.

    There are two scenes in the example project, one with control schemes one without. You will have to restart the editor if you change scenes or nothing will ever work - another bug perhaps?
     

    Attached Files:

  2. viatech

    viatech

    Joined:
    Dec 6, 2017
    Posts:
    55
    Further to this post.

    When you create a new control scheme there is a text box to add a scheme name and under that you can add a requirement. I had no idea what that was for so I left it out. It would seem that you HAVE to put the device requirement in there or the actions don't get associated with the input device.

    So for my Gamepad control scheme I added a "Gamepad" requirement and to the KB control scheme I added a "Keyboard" requirement, both with the "required" radio box option selected. Now the players get the correct controllers and actions, and inputs work as expected.

    REVIEW: Probably needs some UI code to prevent creating control schemes without giving the requirements - to stop my kind of idiot messing up!
     
    lweist3317, MrWy07, qball13z and 7 others like this.
  3. Euromancer

    Euromancer

    Joined:
    Aug 21, 2017
    Posts:
    10
    Thanks, solved my issue!
     
  4. viridisamor

    viridisamor

    Joined:
    Mar 1, 2019
    Posts:
    3
    I'm your kind of idiot. I spent an hour trying to figure out the issue. Finally found the right query to come across this post. Thanks for this! There really should be some message telling users to set a required device.
     
  5. RPowers

    RPowers

    Joined:
    May 14, 2015
    Posts:
    122
    This also fixed my issue thanks! Spend a couple hours trying to figure out why my keyboard wouldn't trigger actions. There really should be some UI or message to warn us that a control scheme needs a device requirement to work.
     
  6. chaozou2008

    chaozou2008

    Joined:
    Mar 13, 2015
    Posts:
    3
    thank you very match, solved my issue! waste a few hours to find why it did not work....
     
  7. qball13z

    qball13z

    Joined:
    Nov 30, 2013
    Posts:
    15
    Had no idea why everything was working fine until I realized the last thing I changed was adding schemes. Thanks to this post I'm all good now, Unity definitely needs to add a UI prompt or just set it by default!