How do I create a split-screen game?

the easy way to do it, is to buy a second wired xbox controller. it would be nice if Epic would add the option to split keyboard and the first controller as separate LocalPlayers with different controller IDs in the same window.

the next easiest way to do it, (although it wont give you splitscreen, it will instead give you 2 separate windows), you can go to your EditorPreferences > Play and set the number of players to 2 and check Route1stGamepadToSecondClient:

45804-editorpreferencesroutegamepad.png

the hard way to do it, is to route all of your input for both players through the same playerController, and using the gamepad to control the pawn of a separate PlayerController. you would have to set up input actions and input axis events that are just for the keyboard, and separate events just for the controller.

then you give your playerController a SecondPawn reference variable. you check if this reference is valid, and if it is, your controller input events tell this SecondPawn’s movementComponent what to do, instead of telling its possessed pawn what to do. if the reference is invalid, you might want the gamepad to do the same things as the keyboard.

when you want to add an extra player, you do it from the gameMode, and make sure to get the pawn from the spawned player controller, and pass it to the first playerController to set its SecondPawn variable. if you spawn a third player, you can pass its pawn to the second playerController, and a fourth player would give its pawn to the third playerController.

then you will have a setup where each gamepad controls the pawn of a different playercontroller than its owner.

and the hardest way to do it, is to hack into the C++ and figure out where the first controller is getting its controller ID from, and changing that code. i haven’t been able to figure out how that works yet. at some point, your gameViewportClient recieves an inputAction or InputAxis, and it knows whether its a gamepad or a keyboard input, so you can probably make a custom GameViewportClient that overrides inputAxis and InputAction, and increment the controllerID if its comming from a gamepad.