Local and Online Multiplayer?

How would I go about implementing both local and online multiplayer? I have a game that has up until this point been local multiplayer, and I have been looking into adding online multiplayer, but I’m stumped as to how to implement online multiplayer while keeping local multiplayer as an option. The best I can see is that I essentially may have to build two separate games, because when using a build with Networking, half my events are split between server/client, but when running local, I need all my events to be running on the single instance of the game.

TL:DR. How do I implement a game to have both local and online multiplayer? Do I build two separate games, or is there a setting that “disables” networking?

It depends how you have the functionality set up as to how easy it is. You totally can set up so that you use a multiplayer connection. There’s steam integration built into UE4. If you go to Edit > Plugings > Online Platform > Scroll down to Steam and enable it. Then go to your DefaultEngine.INI and get the steam integration set up with code from there.

Question though, when you talk about “Local Multiplayer” Are you talking LAN Connection? Or literally 2+ players on the same machine using controllers for inputs or something like so? If its local machine connections then yeah, you’ll have to do a lot of work, but I’m sure its possible, just set up some checks for that in the way you set up the matches.

https://docs.unrealengine.com/latest/INT/Videos/PLZlv_N0_O1gYqSlbGQVKsRg6fpxWndZqZ/index.html

I’m fairly new to Networking myself, I’ve been working through this as much as I can to get networking set up, and there are definitely ways of switching between a LAN connection and an Internet connection.

I’d need to know more information before actually giving any answers. However the tutorial I linked should hold some answers for you.

Thanks for the response. As for local multiplayer, yes I meant 2+ controllers on a single machine. The game I am working on at the moment is essentially a couch party game with a shared camera. So far it’s been purely local, running off of one machine, but I want to add online multiplayer while keeping local multiplayer as an option.

As for networking, so far I have been able to successfully create a dedicated server and tested it both in LAN and online, using a friend’s computer. However, I notice that if I try to run a local game on a build that is meant to be a client, I cant run any of the server functions and events that are neccessary for game flow and game events. I’m pretty sure this is intentional, so I’m wondering if there’s any way I should be handling this, or if the only way to do this is to build a local version and an online version seperately.

You do not need to build two separate modes, if you do not want to.
Implementing local multiplayer generally comes down to using the function “Create Player”. See

for an introduction.

As far as I know, you can run CreatePlayer on the server without problems, it will have the same behaviour as when run in a “local” game. So you can simply run a server (without any client) as a local game and allow additional local players. This will make testing a lot easier, because you do not need to test two different modes.

Can the client also add new new local players? I want my game to be able to be two player split screen on two machines all playing together or four players on one machine. 3 on 1 and 1 on the other. Etc. Any configuration people want to do so there’s both online and local going on on each instance with up to 4 players on one machine or up to four players across four machines.

Yes the client can add additional players. But this is not intuitive: If you need to run CreatePlayer on a Client (which is connected to a server), you cannot use the return value. Instead, you need to use some kind of player activation based on the local player id in BeginPlay of the Controller. This is very tricky, I’m afraid.

im wondering if you got this working, im having some trouble spawning 2 players from another machine, so pretty much what you said 4 players, but 2 on one machine(host) and 2 on the other(client)… getting any number of players on the host is easy, but getting more than 1 on a client is where my trouble is…

Unfortunately I did not. I created a forum and didn’t get any answers there too. Lotodore’s answer was also not specific enough to really help me.