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. Dismiss Notice

Rebind not working

Discussion in 'Input System' started by Shashimee, May 3, 2020.

  1. Shashimee

    Shashimee

    Joined:
    Nov 1, 2017
    Posts:
    7
    Hello, I am using the new InputSystem for my game and have a simple action bound to the Space key on the keyboard.
    I am using the RebindActionUI from your samples and it seems to work alright. When I perform the interactive rebind, the new key is correctly shown on the UI (let's say the A key) but in game, I can only still jump with the Space key.
    I tried to update my Inputs with this snippet after the rebind :
    Code (CSharp):
    1. inputs = new Inputs();
    2. inputs.Player.Jump.performed += ....
    Still, only the Space key makes the player jump. Is there anything I should do after the rebind to update all of my Inputs instances ? Thanks.
     
    tigerleapgorge likes this.
  2. Rene-Damm

    Rene-Damm

    Unity Technologies

    Joined:
    Sep 15, 2012
    Posts:
    1,779
    Note that the rebind needs to be performed *on* those actions. If you use the RebindActionUI component and drag an action from an .inputactions asset in there but then at runtime use the generated C# class, the rebinds won't have any effect as the generated C# code has no connection to the asset.
     
    tigerleapgorge likes this.
  3. Shashimee

    Shashimee

    Joined:
    Nov 1, 2017
    Posts:
    7
    @Rene-Damm Oh okay ! Then what is the point of the RebindActionUI ? Does it have a use at runtime ? Thanks.
     
  4. Rene-Damm

    Rene-Damm

    Unity Technologies

    Joined:
    Sep 15, 2012
    Posts:
    1,779
    ATM it's most useful with PlayerInput or when using .inputactions directly. With the generated C# classes, you can still use it but the action references will have to be set dynamically at runtime.
     
    tigerleapgorge likes this.
  5. Shashimee

    Shashimee

    Joined:
    Nov 1, 2017
    Posts:
    7
    Ok I think using .inputactions might be the way to go for me in this case ! Thanks for your answers :)
     
  6. Shashimee

    Shashimee

    Joined:
    Nov 1, 2017
    Posts:
    7
    Last edited: May 5, 2020
  7. Rene-Damm

    Rene-Damm

    Unity Technologies

    Joined:
    Sep 15, 2012
    Posts:
    1,779
    You're probably missing code to enable the action(s).
     
  8. Shashimee

    Shashimee

    Joined:
    Nov 1, 2017
    Posts:
    7
    Indeed ! Thanks for the answer and good job on the new input system, it really is a great tool :)