I don’t use the input system via “Player Input Component”, but (as described here) with the “Actions Asset” workflow; so I have the wrapper class generated for the actions and reference them via code.
However: I have two player prefabs spawned via code which then “bind” the actions in their PlayerController script as follows:
// PlayerController.cs
private void Awake()
{
playerInputActions = new PlayerInput();
playerInputActions.CharacterControls.Move.performed += OnMove;
playerInputActions.CharacterControls.Move.canceled += OnMove;
playerInputActions.CharacterControls.Jump.performed += OnJump;
playerInputActions.CharacterControls.Jump.canceled += OnJump;
}
But now I control both players at the same time with the keyboard inputs. But I want to make sure that player 1 uses “Keyboard” or “Gamepad No. 1” and player 2 uses, for example, “Gamepad No. 2”.
How can I distinguish this in the code?