How do I create a split-screen game?
I have begun creating a game where I need one player to be controlled by the mouse and keyboard and at least one other player controlled by a gamepad. I can create the second player and enable splitscreen, however I have no control over the second player. How do I do this? My first player that I created is a blueprint "character" and I have extensive blueprint coding within this character to make him move and do other misc tasks. I need the second player to be the exact same, but be controlled by the gamepad instead of the keyboard. Here is the blueprint for my game mode where I create the new characters.
Additionally, here is the blueprint for my first player. As of now, I have my first player being controlled by both the gamepad and the keyboard for testing reasons, but now I need the 2nd player to be controlled by the gamepad instead.
Any help would be appreciated! Thanks a lot guys!
asked Jun 10 '15 at 12:38 AM in Using UE4
For anyone still unable to get a local splitscreen system working, I have created a short tutorial to get you going on your multiplayer game.
NOTE**** This is a blueprint system for creating players driven by separate character blueprints. I used this to help differentiate what each of my players could do in my game. If you are looking for a system where all players are driven by a single character blueprint, simply follow this tutorial until you reach the "Create blueprint characters for each player" screenshot. However, I do believe that this is the most effective method. Let's get started.
-First you will need to create a blueprint enumeration. This will help to control the amount of players in your game. This is optional, but I recommend it.
-Open your enumeration and create an input for 2 players, 3 players, and 4 players.
-Next we will set up the gamemode to create the players. First, open your gamemode event graph and create a variable that will control the number of players in your game. Change your variable type to your enumeration that you created previously. This should be "E - Whatever you named your enumeration". Compile and you should now be able to switch between two, three, and four players in your variable.
-Now we need to set up the gamemode blueprint to create the players. Simply use a setup like this one to create a number of players based on the variable that you just created.
-Now, create a blueprint character for each player that will be playing your game. These can be duplicates of each other or they can have very different behavior, this is up to you. In this case, I only have 2 players so I created only 2 blueprint characters.
-Last step! This step is VERY IMPORTANT. Open each player character and search for the PAWN section in the detail panel. Find auto possess player and by default it will be disabled. For your player 1 character, you must set auto possess player to player 0. This will allow the first player created in game to possess this character. Next set your player 2 character to be auto possessed by player 1, your player 3 character to be auto possessed by player 2, and your player 4 character to be possessed by player 3. This allows each character to be correctly controlled by the players in the game.
That's it! Simply drop each player character into your game! As I stated previously, you can now customize each player individually and reference each player separately in the level blueprint. This is very helpful and will better allow your game to distinguish which players are performing which action!
I really hope this helps somebody get started with local multiplayer! This system, simple as it was, took me over a year to figure out, as I am still relatively new to the software. Let me know if you guys are having any problems with the system! Also, please let me know if something I have posted here is incorrect, seeing as I have only used this setup once, but it worked flawlessly. Thanks so much!
answered Nov 04 '16 at 12:41 AM
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:
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.
For local multiplayer, Unreal cannot do split controllers. Because first keyb/mouse/gamepad/joystick always assign to Player 0. And all other game controllers assign to next player accordingly. Other words, you need to connect 2 or more gamepads.
answered Jun 10 '15 at 11:09 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here