Simply allow first gamepad to control Player 2
So in my game you can either select one player, or local 2 player.
If you select one player, the controller and the keyboard control the first person, and since there's only one, that's fine.
However, if you select two players, the controller and the still keyboard control the first person, and if you have another gamepad then the second one will control the second player.
I'd like to have it so that just the keyboard controls player 1 and the first gamepad controls player 2. Is this possible?
Bonus, detect the number of controllers and if there are two controllers and two gamepads then each gamepad controls a player, and the keyboard controls the first player.
asked Nov 08 '15 at 02:20 PM in Blueprint Scripting
You can do it by going into Project Settings > Maps & Modes > Skip Assigning Gamepad To Player 1. Set it to true and you are good to go.
answered Feb 28 '17 at 11:55 PM
Hello there! After searching a lot, I finally found a solution by talking to MordenTral (awesome dude and author of two amazing plugins). Basically, the clean solution to achieve this is to create a child class of UGameViewportClient which overrides InputKey(...) and InputAxis(...). In the overrides, you can reroute where certain inputs go and both functions have bool bGamepad as a parameter so you can basically use that to determine where you want to send the input. It is necessary to set the Game Viewport Client Class in Project Settings to be the newly created class. You can make this class blueprintable and expose an Enum UPROPERTY to Blueprint so that you can actually create a child blueprint class and can change behavior dynamically at runtime using blueprints (of course the Game Viewport Client Class in Project Settings would need to point to this blueprint class).
Here is my UCustomGameViewportClient class:
Create Blueprint class from this, and you'll see ou can change the Enum to whatever you like.
To change this at runtime you'll need to access this class with UWorld::GetGameViewport(), so make a function in a c++ blueprint function library (if you want to have access via Blueprints):
Once you have that exposed, all you need to do is cast it to your custom Game Viewport class and set the enum to the desired value.
I must say that this works perfectly for me... but I also have input on UI and in that case it isn't working, I still need to find out what happens in that case.
answered Apr 14 '18 at 11:27 PM
There is no simple fix, but a workaround. You can create your own controller class and carry out the necessary operations in its event tick. However, your problems would not end there as you would need some c++ code to disable the split screen once a level is complete, otherwise UE4 splits the screen even when you open a new level or go back to the menu. It's quite cumbersome but possible. It may be better to work for an official solution.
answered Nov 10 '15 at 04:36 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here