My second player is created using GEngine->GameViewport->CreatePlayer(1, …); in a custom GameMode.
The second player spawns correctly, but I cannot control it.
I have a PlayerController in blueprint that handles keyboard input to move the pawn created by the player.
Both players created use the same type of PlayerController, but the keyboard events fire only on the first player.
I have tried changing to CreatePlayer(0, …).
All my characters and controllers have Auto Receive Input disabled, although I have tried all possible values for them.
I have spent hours searching and trying to figure out how to control both players with the keyboard. I want to use WASD for one player and the arrow keys for the second.
The keyboard input is by default allocated to go only to player 0. To change this you would need to subclass UGameViewportClient and override the behavior of InputKey
I’ll make a note to consider whether to add some easier way of redirecting a given device (in the case of gamepads) or to allow sharing of the input device for the keyboard like in this case.
I am currently working on a Fighting Game and I have local players using one keyboard quite easily.
Here is how I do it;
Create Player Character in Game Mode with new controller. Then in first player controller, I cast to the second controller to make things happen for second character. So it looks like 2 people using 1 keyboard, while internally both players are using the first player controller.
But yeah, a new system for local players should be implemented.
Add my vote to this, it would be an extremely useful feature, I understand there are work around but it would make sense to have a more proficient method for this.
it’s actually super simple. he manually set the input in the game input settings, but “duplicated”, so once for wasd and once for, say, the arrows. The player controller (0) then sends the part of the input that he wants to be of player 2 to the player controller (1) using “cast to”. this has to be done this way since the keyboards only sends input to player controller (0)