I’m learning the new inputSystem. I have added input Actions with a control scheme for player one (WASD keys), and a control scheme for player two (ARROW keys) - for a two-player game on the same keyboard.
Sadly, this doesn’t work. I can’t find a way to make keyboard WASD work for one player, and keyboard ARROWS for the other player.
It seems that a player can only have one input device? (keyboard, gamepad one, gamepad two, touch, etc.)
Now I’m hardcoding keyboard input in the player class, but that way you can’t get the equivalent of getAxis() in the new input system
The way I solved it was by creating two separate maps for the two players. The maps contained the same actions, with their corresponding bindings - so one map would have WASD, and the other would have arrows.
I had two instances of a Player object, and I passed a reference to those in my controller script, along with a reference to my InputActionAsset. Then, I assigned the move function of each player to their map.
This is mainly what I used in my code:
InputActionAsset asset;
InputActionMap map1 = asset.FindActionMap("map name"); // The doc says GetActionMap instead of Find, but isn't available on the latest. This works.
InputAction action1 = map1.FindAction("action name");
action1.performed += <whatever function/delegate>;
I don’t understand the new Input System either, but this seems to be a clean solution for this problem. Would love to hear about any other ways of solving this.