Multiple players per client

Hello.

I’m trying to work out what would be the best way to allow for multiple players per client.

What I’m aiming for is multiple players on one client, using either keyboard or controllers, and that client is able to connect to a server with other players playing in the same fashion.

Clients would probably have to manage their local players and inputs, and send details about the players when joining a game.

Maybe I can override AGameMode::Login to create a controller for each player?

Any help here would be appreciated, thanks!

Any update on this?

Any news on this?

Why you even question that? Ofcorse you can, there also this function, they all been virtual for that purpace:

https://docs.unrealengine.com/latest/INT/API/Runtime/Engine/GameFramework/AGameMode/SpawnPlayerController/index.html

But if you override some function you should first check whats the original code, what you will override since if you don’t execute parent code you might incidently paralize or bug out some other code in class:

https://github.com/EpicGames/UnrealEngine/blob/dff3c48be101bb9f84633a733ef79c91c38d9542/Engine/Source/Runtime/Engine/Private/GameMode.cpp#L1056
https://github.com/EpicGames/UnrealEngine/blob/dff3c48be101bb9f84633a733ef79c91c38d9542/Engine/Source/Runtime/Engine/Private/GameMode.cpp#L1252

If you look at them they don’t look complicated

Overall i recommend you to explore entire GameMode class in functions that really interest you, you might find different and less invasive methods to achieve what you want to achieve. Really don’t be shy to explore engine code, your game code physically becomes part of engine, so better you know engine code the better you know what to code.

It’s been over 2 years since I asked this question, and in that time I’ve learned a lot about UE including how to dive into the source and answer my own questions, however when I asked this I knew almost nothing and looking through engine source was not something that was easy for me at the time.

For anyone else finding this looking for a solution, I haven’t required this functionality since I initially asked the question, but I did a quick test just now and found that if you add a player to the client via “debugcreateplayer -1” console command it seems to add another player connected and controlled through that client completely out of the box with no extra code required.

I added an answer just now, hope that helps.