x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

How to set up simple online multiplayer?

I've been sifting through all the documentation on multiplayer all day and I'm rather confused on what I should be doing to implement multiplayer. I've been reading about online subsystems and client/server models and sessions and I'm not sure if these should all be used in conjuncture with each other or if each one is used for a different purpose.

Anyway, what I'm asking is for someone who knows how servers and UE4 works to help me understand what I should be doing here.

I want to be able to host a server on my computer and let my friend hundreds of miles away be able to connect to it.

I was also going to implement a server list for easy server lookup but if I have to do something like setup my own online subsystem to do that then I won't; this is primarily a project for my friends and I to use so it's okay if it's rough around the edges.

Thanks.

Product Version: UE 4.11
Tags:
more ▼

asked Jun 18 '16 at 04:35 AM in C++ Programming

avatar image

MrShmid
47 16 15 19

avatar image MrShmid Jun 21 '16 at 11:09 PM

Ok, so either no one knows how this stuff works or no one's seen the question. Either way, bump.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

To anyone following this: I fixed it (in a way). I was able to get session-based multiplayer working by using Steam's subsystem. Rama made a cool guide on how to do this here. For session setup, I used eXI's guide here.

I'm still not entirely sure how to run a listen server through the console or through code, but I did solve my original problem.

more ▼

answered Jul 04 '16 at 07:06 PM

avatar image

MrShmid
47 16 15 19

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

Your question is quite general. Replication should work out of the box, you don't need ot deal with OnlineSubsystems, first make your game work just by connecting client to server

First thing you need ot understand is that there not much difference from local and multiplayer player, they are added and playercontroller for them is created and you game should handle that, so start with that. To add a player you use either CreatePlayer() function (in viewport or gameplaystatics which also work in blueprints), or input "debugcreateplayer 1" (if this still works) to console.

Now UE4 online multiplayer is based on state replication, host holds master copy of state and clients tries to sync that state and input there own data so all clients (and host) are synced, this system is good for shooters and any other games that have real time action (not just action games) but it's overkill for turn base or games that don't need much information to be synced (but you can do function call replication for that using system that UE4 have) or fighting games which require more controller input based replication. I never played with replication but i think as long you use dafault movment system and oyu game can handle more then 1 player it should work out of the box, so start up the server and try to connect client (remeber about port forwording):

https://docs.unrealengine.com/latest/INT/Gameplay/Networking/Server/

Now setting up replication is all about deciding what should be replicated and what server should listent to, make everything sync in correct way. You need to remember that computer memory can be easily altered locally, it's main method of hack injections, so don't allow client to control anything then related to player, client should only do what player is allowed to do, host is ultimate authority which should be on guard of that and it should check if it's not getting some ridicules data from client, like player teleporting somewhere.

You should conceptrate on replication, things like OnlineSubsystem are just support social services like Steam works, PSN or XBox Live you can add that later if that confuse you, but you need to create a session in order for you game to be discoverable in LAN.

If oyu want more tip say what kind of game you making

more ▼

answered Jun 22 '16 at 12:38 AM

avatar image

Shadowriver
36.6k 930 169 1111

avatar image MrShmid Jun 25 '16 at 07:53 AM

I can't make a client connect to a server. Either I messed something up or there's some setup I haven't done.

Well I tried running a server from the console and having my friend connect to it (through the console) and it didn't work. I tried moving the server to a different level to make sure he wasn't connected and he wasn't.

I'm basically making the turn-based strategy board game Risk in UE4. I don't really care what I have to do to make it work right now, I'm just trying to find something that will allow me to make a server and have someone somewhere else connect to it.

P.S. I understand what replication is and I'm pretty sure I know how to use it.

avatar image chrismcr Jun 25 '16 at 02:50 PM

If your server is behind a router you'll need to set it up to forward port 7777 (by default) for a direct connection to work.

If you want to avoid port forwarding you could use steam, but be aware it requires seamless travel to move to new maps once players have connected.

avatar image Prithvi Singh Jun 26 '16 at 08:40 AM

Hello
how do I test multiplayer for steam? (Not greenlit yet).how do I know if its working or not I did setup but unable to join server, no one replied to my question so I am posting it here.

avatar image MrShmid Jun 26 '16 at 08:55 AM

Right, forgot to mention the port forwarding. Yes, we both tried port forwarding to 7777. Still didn't appear to work.

avatar image chrismcr Jun 26 '16 at 12:26 PM

Okay, so how are you connecting on the console? I've never done it that way myself so not sure what the 'correct' way is in that context. And do you have any logs from the server or client? It's possible the connection is being made then immediately dropped.

avatar image MrShmid Jun 28 '16 at 09:23 PM

I use the commands from this page. I'm using a packaged project so I change 'UE4Editor.exe' to 'ProjectName.exe'

To start a listen server, I used ProjectName.exe MainMenu?listen -game

To connect, my friend used ProjectName.exe [my IP] -game. We also tried connect [my IP]. I don't know if there's supposed to be some indicator that a connection was made, and I'm not entirely sure how to do that. I think there was some command in the GameMode that fired when a player connected to the server but I forget what it was.

avatar image Shadowriver Jun 26 '16 at 03:30 PM

Well if you making card based game you could build up your own protocol with sockets, if you going to use UE4 replication, don't use any movment replication, only function calls and maybe some varable replication if needed

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question