Strange Issue with Rebinding - Action/Trigger is called multiple times after Rebind

Hey, another head-scratcher. I’ve “successfully” integrated the new Input System into my project, and for the most part (knock on wood) everything is working. I noticed some odd behaviour though: If I don’t rebind any controls during a play session, everything is great. If I rebind an action to a different input/button, it calls multiple times (Specifically, I am calling "if (controls.Player.Attack.triggered) ).

I’ll also just add, all the relevant actions in the ActionMaps are just type of Button, with no interactions (adding the Press Only interaction doesn’t change the problem, as I guess that’s the default state for a button anyways?)

On a controller or keyboard, if I just tap the button quickly it preforms as expected. If I hold the button down for any longer than just a tap, I see an event called when the button is released as well. It’s far worse with a controller trigger pull, which sees an inconsistent number of between 2 to 4 calls on activation, and another 3 to 5 on release.

Any insight would be appreciated! I do have the following code in my ControlsManager script, though I’m currently only making use of the “canceled” / is_Pressed=false lines. Would I have better luck if I asked for input based on the is_Pressed line? I think I was trying this and ran into issues previously, hence why I’m currently calling on the triggered event.

controls.Player.Ability1.started += context => Ability1_Pressed = true;
        controls.Player.Ability1.performed += context => Ability1_Pressed = true;
        controls.Player.Ability1.canceled += context => Ability1_Pressed = false;

It’s just super odd that it only happens after a rebind operation has occured, I’ve tried looking through my InputActionMaps and can’t really come up with any reason for this behaviour.

The code for my rebinding script is below (Caution: Extremely inexperienced and uneducated human, I apologize if any of this is ultra gross :stuck_out_tongue: )

public void RemapAction()
    {

        //print("TODO: Display "Enter New Key For This Action" Tooltip");

        ControlsManager.controlMan.controls.Player.Disable();

        rebindOperation = actionToRebind.PerformInteractiveRebinding()

            .WithControlsExcluding("Mouse")
            .OnMatchWaitForAnother(0.1f)
            .Start();
        rebindOperation.OnApplyBinding((rebindingOperation, path) =>
        {
            actionToRebind.ApplyBindingOverride(path);
        });
          
            ShowNewBind = true;
    }

and further down after some UI stuff;

if (rebindOperation !=null)
        {

            if (Player2Rebind == false)
            {
                if (rebindOperation.completed && ShowNewBind == true)
                {
                    //Update Binding Graphic / String
                    var bindingIndex = actionToRebind.GetBindingIndex();
                    ControlsManager.controlMan.controls.Player.Enable();
                    rebindOperation.OnApplyBinding((rebindingOperation, path) =>
                    {
                        actionToRebind.ApplyBindingOverride(path);
                    });
                    rebindOperation.Dispose();
                    CurrentBinding.text = actionToRebind.GetBindingDisplayString(bindingIndex, InputBinding.DisplayStringOptions.DontIncludeInteractions);
                    ShowNewBind = false;
                    ControlsManager.controlMan.BindingRefresh();
                    if ((currentSelected.name == "grab") && isGamepad == true)
                    {
                        GrabBinding.text = Grab_GP.text + " +";
                    }
                    else if ((currentSelected.name == "grab") && isGamepad == false)
                    {
                        GrabBinding.text = Grab_KB.text + " +";
                    }
                }
            }
}

Once again, I find a solution not long after posting… Hopefully it’s helpful for me to update my queries in case others run into the same issues?

I still can’t determine what’s going wrong, BUT, I did some tinkering, and it seems if I set interaction on the Action/Button to “Press only” and then change the Button Press Point to 1, it only fires once. I guess this makes sense, since the button will pass the default 0.5 press point while being pressed AND released, but it still seems odd - why does it work as desired before a rebinding, and then breaks afterwards? Oh InputSystem, you continue to baffle me :stuck_out_tongue:

edit to add: Important to change the Button to Pass Through > Button in the action map.

This is an artifact of RebindOperation going and overriding every binding when not instructed to override a particular one. That in combination with the binding resolver happily resolving the same control however many times it was bound to the same action leads to the behavior you’re struggling with.

This has been fixed in the current develop branch (by this PR) and will roll out in the upcoming 1.1-preview.3.

1 Like

Thanks for the update Rene!