Restrict binding resolution to a specific device
By default, actions resolve their bindings against all devices present that the Input System is aware of (that is, those listed in InputSystem.devices). For example, if there are two gamepads connected, a binding to <Gamepad>/buttonSouth picks up both gamepads and allows the action to be performed from either gamepad.
You can override this behavior by restricting an action asset or individual action maps to a specific set of Devices. If you do this, binding resolution only takes the controls of the specified devices into account.
To restrict an action map to just the first gamepad:
- Set the
.devicesproperty of the action map to an array containing a reference to the first item in theGamepad.allarray. For example:
actionMap.devices = new[] { Gamepad.all[0] };
Note
The Input System's user management feature and Player Input component make use of this automatically. They set the InputActionMap.devices for each player automatically, based on the device that is paired to each user.