Local Multiplayer with 1 keyboard

Hey guys,

I’m trying to make a game that works like a GameJam entry from february, 2015:

I want the 2 characters to have 2 different meshes, using the default Pawn blueprint class, and both should be controlled by 1 single keyboard. Sadly, I have no idea how to achieve this.
I made 3 blueprints to get the same look as the GameJam entry. 2 of them are Pawns and the 3rd one is an actor with a camera attached, but now, I have no idea how to posses the 2 Pawns and still have 1 keyboard to control both of them :3.
I really appreciate every help, this bugs me so much, because this has to be simple and yet I don’t see how I can implement this easy stuff, I can’t even go sleep… hahlp! <3

So for creating different players you can use createplayer an example here:

As to 2 character on one keyboard it seems simple I’ll have a bit of a play with it but you could make a custom playercontroller or do something like using the camera actor to get a reference to the players, and then using the instance of those pawns as the target for inputs.

Okay, I saw that code with create Player somewhere, but it’s a bit confusing. When we create a level, we can set the Default Pawn Class in World Settings. When we put a Player Start in the level, the Default Pawn Class will spawn at the location of Player Start, if we don’t have a Player Start, it will spawn at 0,0,0. So, what exactly is CreatePlayer doing here? Does it… only create a ControllerId? which we have to combine with GetPlayerController to posses a SpawnedActor? What’s up with the CreatePlayer + GetPlayerController combo? <3

I tried to spawn my 1st Pawn at the player start with a camera. The controller of the 1st Pawn is spawing the Controller for the 2nd Pawn and spawning the Pawn itsself. In the same code I want to add the movement of the 1st Pawn and give GetControllerPawn as target while giving the 2nd Pawn a reference of the spawned actor as AddMovement target. 2nd Pawn still not moving, does it correlate with the ControllerId something? <3

I swear, this whole topic is a dark hole for a lot of users. Many questions and only some hints on documentation to learn how to code in C++ and the whole Networking thing or many tutorials are outdated or people just plug in 2 Controllers and every problem solved. Can someone make a kickstarter for making a Fighter Game with all Multiplayer options, this guy will be rich! :3

Reading Kitatus Solution now…

So take a look at this I have it firing from my level blueprint on begin play.
The transform in the “make transform” node is the location and rotation to spawn the pawns, what this is doing is creating a playercontroller 1 & 2, then spawning and possessing these pawns to each controller, think of it like this. Controller0 is player 1, controller1 is player 2 (locally doesn’t work that way with net play as controllers aren’t replicated).

Then in a persistent actor (camera/level) I’d get all actors of class, set index 0 to player1, index 1 to player2 reference of the pawn, and use those to drive something like this lines of this (obviously you don’t need the cast if it’s inside the same bp), it’s 4am here though I’ll look over it again in the morning but this should get you started, it is a similar version to how I have it set up for local play in my fighting game.

p.s. don’t forget using controller -1 means getting the next available number.
p.p.s. I should probably have pointed out I don’t use player start, I use this function to spawn the players instead.

So, when creating the players, where do they know which controller to use? And what GameSettings are you using then, PawnClass None, other default?

*Because when I use your method I get an error: Accessed None “CallFunc_CreatePlayer_ReturnValue” from node Possess in graph “EventGraph” in blueprint “myMap”

Default pawn spectatorpawn, it sounsd like you haven’t connected the nodes properly, could you take a screenshot?

So, I created a new level (the default one with a platform). I created a DefaultPawn BP, called it Annie. I changed “Owner No See” to false, so that I can see the player ingame.
*I deleted the PlayerStart. Then I put this code in my LevelBP, but I get the message from above.
**And I’m using a GameMode with DefaultPawn, and all other settings are default.


Ok I made something quickly here using the rolling ball template, doesn’t have 2 keyboard movement but has the spawning system for it in place (plus a little camera logic). It should be enough to get you on the right track.

You are getting the same error :3

The error pops up but it works in game so it’s all good :).

Nevermind, after working on this messy stuff for 2 days, I switched to Unity, the implementation is easy done on a single keyboard. I let this thread open, if someone has a clean solution for this without getting any errors and what not <3.

*Well, it might work, but the error is not there for fun, it’s obviously using a bug/exploit, which can’t be a real solution. I understand UE4 is not for this kind of input and it’s way easier to set this thing up with 2 Xbox Controllers, but on a single keyboard… yeah… I might miss something, but I’m fed up with my search, this special task seems to only work with a really poor workaround.

You can just use id -1 (next available), or 1 & 2 then you won’t get that error.

Actually, it looks like you don’t need any other controller or new ID. This is how it works now.

Put a PlayerStart in your Level. Change the GameMode settings to your 1st Pawn. Create a MasterController, change the GameMode settings to MasterController. In the MasterController, get all actors (2 times: 1st Pawn and 2nd Pawn). Save the reference. Add your Input under Engine settings. Use your P1_Input_Settings -Event and use AddMovementInput, put your 1st Pawn as target. Use your P2_Input_Settings -Event and use AddMovementInput, put your 2nd Pawn as target. Basically, the MasterController handles Pawn1, the MasterController also has a reference to Pawn2 and is controlling it. I don’t know how to deal with the 2nd Pawn and giving him a “real” Controller, but controlling him over my 1st Pawn and the MasterController works fine, gives no errors and should make everyone happy <3.

*I hate that I love UE4…