C++ Multiplayer Tutorial Needed

Hello all. I’m learning Unreal after having used several other engines. I was hoping to jump into multiplayer but I haven’t been able to find a tutorial I need. I’m looking for a tutorial that:

  1. Starts from the very beginning with a third person C++ template
  2. Jumps immediately into how to do multiple players
  3. Proceeds to establish server/client communication with player movements and any one other item, like health
  4. No other distractions like weapons, explosions, particles, time of day, etc.

I know this is a very specific request but I would really appreciate if someone can point me to something like this. Tom Looman’s tutorial looks incredible but it started off with an existing project which looked like it already had a bunch of stuff in it that I don’t need and may confuse me instead of help. I’d like to start clean, from scratch.

Thank you for any help.

Hm so you want a tutorial about Replication in general? Nothing about creating sessions, joining and hosting in C++?
Because the Session thing is quite complicated to explain. You will have to look into the ShooterGame or ask someone
who might already done a basic session setup.

The replication thing in the other hand is already explained by Epic itself. The idea behind it is the same in C++ and BP.
So to understand the background, you can take the BP stuff.

The C++ Part now, is only the way to need to define functions and variables.

The normal way is, that you set the bReplicates bool to true, add the Network.h as an include
and then create your Variable and Functions that should replicate.

How to do this?

The UPROPERTY and UFUNCTION macro gives you everything you need.

For example this:

    float Health;

will create a replicated float variable. You now need the general function that takes care of the replication.
It is everytime the same function for all replicated actors:

GetLifetimeReplicatedProps(TArray< FLifetimeProperty > & OutLifetimeProps) const

In there, you call the “Super::GetLifetimeReplicatedProps(OutLifetimeProps)”
and list all your replicated variables, with and without conditions:

 DOREPLIFETIME(AYourCharacter, Health);

Functions are working similar. But before i continue copy pasting stuff from the wiki, i will just leave you the
link to read through it and see yourself how to define variables and functions for networking.

If you want to learn about general networking, you might want to check out Epics Youtube Channel (Unreal Engine)
and their Network tutorial.

Or you visit my youtube channel, and check out my stream recap about networking. Although i always say, that i
can’t guarantee that it is pretty good. I just talk about how networking works and show some images. Maybe it helps you (:
(: Feel free to ask question if you still have them after watching the videos and reading the wiki.

I don’t know about sessions but like I said, I’m just looking for the basic minimum of two computers (or connecting and moving player positions and updating health (as host and client). If that can be done without sessions, I’m set to start.

Thank you very much for the detailed post. I’ll give it a shot at home.

You need sessions to create server hosting and joining. But for testing you can just start the Game in Editor with 2 or more players. This will directly create a connection.

You can also use the BP nodes to create a session etc. This is straight forwars and you can have a look at the Shootout Game in the learn tab. Keep in mind that is BP only.

Movement is synched for characters that have a movementcomponent and bReplicatesMovement equal true.

The rest is pretty basic. Like i said. Watch the videos and you will get into it. It will just take some time.

there was this multiplayer stream - - there is also the shooter example

Multiplayer Stream is BP only. Because the Shootout Game is BP only. The ShooterGame was mentioned and is still way too heavy to get into C++ networking.

SG is a great learning resource, though it could do with a hella-lot more comments in the code to explain what the heck is going on… especially in the online session stuff. Worked out most of it, but that stuff is just beyond me atm.

Rama’s helpful tutorials on the Wiki and ShooterGame should be all you need for Multiplayer stuff. It’s honestly pretty easy when you get the gist of it.

It really isn’t.

The resources provided are great but NOT a tutorial that cuts to the heart of here is what you need to implement an online multiplayer system with Unreal and a game server. Instead of trying to piece mill together several disjointed resources or finding the time to go through the entire Shooter Game code (which is excellent onlyif you have the time to do so), can there please be a simple to the point C++ tutorial on what is needed to implement this in Unreal using the OnlineSubSystem if that is the best practice for doing so.

This thread is dated so I am hoping that there has been some tutorial (written especially) that has addressed this issue. No one seemed to really answer his question other than to point to several resources that are useful only AFTER you have an understanding of how to implement this using Unreal.

We don’t have a tutorial for everything, but the basics are covered (BP and C++) in my Compendium:

This also covers Session stuff in C++ if you follow the mentioned link to the Wiki.

The Wiki entry might be a bit outdated though, so it could be that the code does not compile or similar,
but someone who wants to create Multiplayer Session stuff in C++ should be able to fix those.
The base logic and idea of how to manage sessions stays the same.

Your compendium is a well made and good to read introduction into ue4 networking. Thanks a ton!

Yup, December 2018, 4.21. Learning how to handle sessions in C++ is still cryptic as hell. There’s 1 Udemy course that seams to teach this stuff, but it’s bugs me there’s no official documentation or template for any of this! There’a a whole lot of info on how to do it in blueprints though.
The few good sources mentioned in this thread are obsolete and unusable as too much has changed in the engine since they were made. The wiki itself is terribly broken too.

So… any ideas?