I’m struggling with this issue like forever, although I should have not, but I’ve done a lot of researches about this issue and no approach would work for me.
Please, Help me to get my development cycle forward, because this issue is really slowing it down.
what is the most working approach to control 2 different characters using Keyboard Inputs, but sharing one Camera…
I’m only able to control only one Character, why there’s no way controlling both?
Note that I’m working with a fresh new ThirdPersonProject Template without any modifications to anything.
FINALLY I’VE MANAGED TO DO IT! After a lot of researches and headaches, it turns out that the answer is a little bit tricky and requires overriding your key mappings over some base engine classes (i don’t currently remember), but what I knew that The engine is limiting using keyboard for multiple Players, and instead it forces using Keyboard for controlling whoever Character possessed by Player 0, and the rest of the possessed characters are controlled by Gamepads.
I really don’t remember the steps, but I know you should search about an article of overriding keyboard controllers in Unreal Engine, and you should find an article talks about how to do this step by step.
after that you should proceed normally with your workflow: me myself I’ve created 2 players in a level blueprint, using Create Players Node, and I’ve set its index number to a MAX Array beginning from 0 to 1.
then I’ve created 2 separate characters that each of them has different key mappings inside of his blueprint, then in their Auto Possess section: I’ve set Auto Possess to Player_0 (for the first character), and for the second character I’ve set Auto Possess to Player_1. I’ve also deactivated their camera components, and I’ve Set View Target for A Unique Camera Actor which tracks both of them.
Thanks for your answer! But I couldn’t find the article of overriding keyboard controllers, could you please tell me which section you found it in Unreal Engine?
instead of that I will give you the game viewport client (subclass) headers which is pre-edited to remove the restriction of keyboard. … follow these steps:
Download the attachment and extract the files.
Move both files to <Your Project Folder Path> \ Source \ <Your Project’s Name Folder>.
Open your project.
Compile these two files if needed (using visual studio)
Open your project settings in the engine and select General Settings.
Under the Default Classes header you shall find Game Viewport Client Class
change it to MultiplayerViewPortClient (which the customized subclass) instead of GameViewPortClient.
now in order to spawn the players you will have to create players in your level blueprint. (in my case I’ve created 3 players: one for the master camera actor which tracks both of them, and the others for my spawned character)
Auto Possess your characters with players (according to how many players you want to possess or to have an individual controller)in my case I've possessed MainCharacter with Player_1 , and TheSecondCharacter with Player_2 , and the MasterCameraActor with Player_0
map your special keyboard inputs to each one of them.
glad to help :)… but, what’s the name of your project? where its location? do you have visual studio 2015 (or 2013)?
I would suggest to open your project and create the sub-class by your self (in this case create a subclass of GameViewPortClient) and name the subclass mutliplayerviewportclient (IMPORTANT), visual studio well auto compile and build the files for you… after that, you should locate and open the two generated files (the header, and the source code by Visual Studio), and on the other hand open the 2 files I gave you in the attachment, then Copy their code lines and paste them in your 2 generated files accordingly, at last… Compile and wait for Hotreload proccess to complete and continue with the tips I gave you.
Following your tips, I have succeed changing it to mutliplayerviewportclient, and after I created the subclass, the Source folder appears, really thank you!
When I create another 2 players and set view target to a specific camera, the whole scene is black! Have you ever met this problem? Besides, I use “is player controlled” node to test if the character is controlled, it prints false, that means it does’t work…I’m so confused about this…
I solved the view problem by setting “Edit - > Project Settings-> Maps&Modes → Use Splitscreen” to false and set only player 0’s view target to the specific camera, that does make what I want! And for the "is Player Controlled‘ Node problem, though it still prints false, I found that the other two characters can respond to their keyboard input event, that’s great for me!
Thank you again for your kind help!
sure … as long as the character can be possessed by a controller then it should work without problems.
take into consideration that this workaround may get out-dated in new engine releases.