How to setup input for local multiplayer without split-screen
To bind actions and axes in the character blueprint class, I may have multiple such character instances for each new APlayerController. Merely 1 Action Name (e.g. avoiding
There exist similar questions, but they are either: not specific, outdated, or lack answers. With this question, I am hoping to provide a good reference point for anyone wanting to setup a local multiplayer (couch co-op) game.
What I've tried:
When I bind actions and axes (delegates) in the
The error thrown during runtime is:
A common solution can be found in this wiki post it seems. In short, overwrite
As mentioned previously, this would require the project to specify a unique Action Name for each player index e.g.
There's are also some points worth mentioning:
Hopefully there are some common best practices to tackle this problem. Any suggestion is very much appreciated!
PS Here is the related gamedev question.
I tried the template approach, where it overrides
For some reason this reminded me to include
answered Mar 07 '19 at 07:11 PM
The first device of any type is bound to Player 0 - so the Keyboard, Mouse, first Gamepad etc.
You've already seen the solution to increment the Gamepad (so you can have one player on Keyboard, second on Gamepad and so forth). I added a simple boolean flag to my project, so that if there are 4x gamepads, then all players can use them. Whereas if players want 4 player, but only 3 pads and a keyboard, you can quickly switch the flag.
Now, what you've said with the Player Controller needing different function binds to the Character... I think there's something wrong with your setup.
For every player that joins, a Player Controller will be created. If you've set up your default Player Controller and Default Pawn, in your projects Maps and Modes (or overwritten them in your map) then each PC will control each Pawn (Character). They'll know exactly which one they're connecting to. If you use "Get Controlled Pawn" within the controller, when passing on a function, you can then cast to your Pawn/Character and call the appropriate methods.
If you use "PlayerStart" (either in one location, or 4 locations, if you want strict offsets for all players) then each Pawn will spawn at one of the PlayerStarts. I wanted strict spawn locations, so I know that there are 4x PlayerStart's, and I set them accordingly.
Lastly, if you're not doing Split Screen, you might need to overwrite the Player Camera Manager, in the Player Controller, so that it points to a shared camera... that's also what I've had to do.
answered Mar 08 '19 at 02:01 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here