I’m wondering if it’s possible to create a custom keybinding system using the new input system.
has anyone tried it?
Hi! It is indeed possible to rebind your inputs with the Input System. You will need to use the “PerformInteractiveRebinding” function.
Here’s an example from my code :
actionToRebind.Disable();
rebindingOperation?.Dispose();
rebindingOperation = actionToRebind
.PerformInteractiveRebinding()
.WithTargetBinding(onKeyBinderClicked.KeyBindingProfile.GetBindingIndex())
.WithControlsExcluding("<Mouse>/position")
.WithControlsExcluding("<Mouse>/delta")
.WithExpectedControlType("Button")
.OnMatchWaitForAnother(0.1f)
.OnCancel(OnRebindCancelled)
.OnComplete(OnRebindCompleted)
.Start();
For some reason I can’t call this method when clicking on a button
it’s not showing on the list
void RemapButtonClicked(InputAction actionToRebind)
{
var rebindOperation = actionToRebind.PerformInteractiveRebinding()
// To avoid accidental input from mouse motion
.WithControlsExcluding(“Mouse”)
.OnMatchWaitForAnother(0.1f)
.Start();
}
The signature doesn’t match.
Would recommend taking a look at the “Rebinding UI” sample coming with the input system package (can be installed from the package manager window with the input system package selected; there’s a list of samples there). May give you a headstart.
I tried looking at the “Tanks” sample, and it still didn’t worked out.
I’ll try the “Rebinding UI” one.
Can you explain what you mean by “signature doesn’t match”?
Edit:
I copied the code from rebinding ui and tried it in my game.
it seems to work, no errors + the icons change when I try to rebind, but the rebind itself doesn’t work.
the same old key still does the same and the new one does nothing, for some reason I can’t “save” the changes