
Welcome to the Unreal Engine 5 C++ Multiplayer CRASH COURSE!
We discuss Peer-to-Peer, and how this differs from the Client-Server Model, which is what Unreal Engine uses
We learn how to test multiplayer, setting the PIE to different net modes including Standalone, Listen Server, and Dedicated Server
We learn how to set up a LAN connection between two devices to test multiplayer
We set up a plugin to host Listen Servers and connect to sessions through Steam
We discuss how Actor replication works and look at properties for enabling Actor Replication and Actor Movement Replication
We discuss the concept of Authority and what it means for Actors on Client and Server, and the Local and Remote Net Role
We discuss Actor and Component attachment and how it works in multiplayer
We discuss Variable Replication and how variables can be designated as Replicated
We learn how to fire off functionality in response to variables being replicated
We learn how to restrict replication to certain conditions
We learn how to toggle replication for a variable on or off depending on a condition we can set at runtime
We learn about the concept of Ownership and how it relates to owning connections for multiplayer
We learn how to replicate variables on Actor Components and how their ownership is set automatically to their owning Actor
We learn how to call code on the server and execute it on the client
We learn how to call code on the client and execute it on the server.
We learn how to call code on the server and execute it on the server and all clients
We learn about validation, allowing us to kick the client for sending invalid data
We learn about the concepts of Relevancy and Priority in multiplayer
The Game Mode keeps the rules for the game, including the default classes that are automatically spawned
The Game State is for storing state related to the game. The Game State replicates to client
The Player State is for storing player-specific state. It is replicated to clients
The Player Controller is associated with the owning net connection and only replicates to the owning client.
The Pawn/Character class replicates to all clients, and shares its owning Controller's net connection.
The HUD and Widget classes are cosmetic and local to the player. They shouldn't be used for replication
There are some important caveats to be aware of when choosing whether or not to use the static accessor functions.
We learn about seamless and hard travel, the different travel types, and how to initiate seamless travel
We implement seamless travel
It's time to learn Multiplayer Gameplay Programming in Unreal Engine!
In this CRASH COURSE, you will quickly learn the fundamentals of Unreal Engine Multiplayer. You will gain the skills to program multiplayer gameplay in any game genre!
Many students struggle with multiplayer. Trust me, I've been there! In my 10+ years of experience of Unreal Engine gameplay programming, I've learned many lessons the hard way. I've found that multiplayer gameplay programming can be easy, as long as you understand the core principles behind multiplayer theory and how Unreal Engine's framework is built around multiplayer at its core.
To program your games for multiplayer, you don't have to be an expert. You simply need to learn the basic concepts behind what makes multiplayer games work. This course is a condensed summary of the core principles you must understand to program multiplayer games.
After completing this course, you will understand the fundamentals of multiplayer theory, how Unreal Engine implements multiplayer, and how upgrade your single player games to multiplayer, and how to structure your games for multiplayer from the start of your project's creation!
This course dives deep into multiplayer theories, and you will be presented with a challenge to test your understanding of each topic so that you can get hands-on experience implementing each technique. After trying out each challenge on your own, you will then watch me solve each challenge and provide you with the steps to complete the problem. Each topic is summarized in a concise recap, and each section ends with a quiz to test your understanding so that you can continue onto the next topic with confidence.
This course is structured into the following sections:
MULTIPLAYER FUNDAMENTALS
We will introduce the core multiplayer terms and concepts, including:
The Client-Server Model - how it differs from Peer-to-Peer connections, and how Unreal Engine uses this model
Testing Multiplayer - How you can easily simulate standalone, listen server, and dedicated server games in the engine's Play-In-Editor (PIE)
LAN Connection - You will create a LAN game, connecting with other computers in your own local network
Listen Servers Via Steam - I provide you with a plugin that allows you to quickly connect to other players via the Steam Online Subsystem
ACTOR REPLICATION
Actors are the heart of Unreal Engine levels. Actors possess the capability to replicate.
Actor Replication - You will see how easy it is to enable replication for Actors, how this allows for the replication of variables, and how to replicate movement to sync the server and client versions of each Actor
Authority and Net Role - Once you understand these simple yet crucial concepts, you will understand how to determine which machine a given Actor is on, affording you the power to make important gameplay decisions for your logic
Attachment - All games involve some form of attachment. You must learn how attachment works in multiplayer for Actors (or doesn't work, if you don't know what you're doing)
Variable Replication - The crux of multiplayer programming. Replicated variables are the workhorse of all multiplayer games and you will see just how easy it is to make them (and thus how responsible you have to be)
Rep Notifies - Sometimes, you just want to trigger a response of a variable's replication. Rep Notifies are functions designed to trigger in response to variable replication, and even access the pre-replicated value.
Replication Conditions - Variables replicate when they change. You have the power to decide whether that happens and when, and to which machines, under what circumstances. You learn how in this lecture.
Custom Rep Conditions - Your games may grow complex. You may find that you need a variable to only replicate sometimes, based on a custom condition you concoct. You will learn how.
Ownership - You cannot program in multiplayer effectively unless you understand what Ownership means in Unreal Engine. This includes owning connection: which machine is in charge of the object in question. This will be demystified for you in this lecture.
Actor Components - Components can replicate too, but you need to understand how that happens, and how their owning net connection is tied to their owning Actor.
REMOTE FUNCTIONS
One of the most powerful tools in Unreal Engine's multiplayer framework, remote functions do what replicated variables cannot.
Run on Client - When you need to call a function on the server and have it execute on the owning client, Client RPCs are your go-to.
Run on Server - While replication only works from server-to-client, Server RPCs are how you get information from client to server.
Multicast - With great power comes great responsibility. To call a function on the server and have it run on all clients, Multicast RPCs are the tool to use.
RPC Validation - Multiplayer programmers will quickly learn that they can't trust clients not to cheat (or at least try). Validation functions allow you to make sure the data looks good, or kick the player otherwise
Relevancy and Priority - Net updates aren't just always happening - sometimes, Actors aren't relevant to other Actors. In addition, some Actors must replicate more often than others. This lecture shows you how relevancy and priority works.
CLASS FRAMEWORK
Understanding which class is designed for which task can greatly simplify your project's overall structure. You must understand what each core engine class is used for to program your games for multiplayer effectively.
The Game Mode - Avoid noob mistakes like trying to access the Game Mode on clients. Learn how the Game Mode dictates the rules of the game and the default classes that are spawned
The Game State - Information about the game, which needs to replicate to clients, is stored on this class.
The Player State - Where should you store your players' scores? Their teams? Player-specific data rests on this very important class
The Player Controller - Representing you as a player, the Player Controller owns your net connection and your Pawn or Character traces its ownership back to this class
Pawn and Character - Every player needs a visible Avatar. How do they work in multiplayer? This lecture has you covered
HUD and Widgets - How are these visual elements handled in multiplayer? Can you replicate them? (spoiler: you can't!)
Static Accessor Functions - Why do we always call these functions, passing in a 0 for the player index when we don't really know what to pass in? Beware of the pitfalls when using these static accessor functions, and the alternatives you can use instead when unsure
TRAVEL IN MULTIPLAYER
At some point, your game needs to change levels. All connected players in a multiplayer game must be moved to another level. How does this work? You will learn how.
Travel - We discuss the different travel types and how to implement them.
Implementing Seamless Travel - The final challenge to this course, you will implement seamless travel, migrating each client in the game to another map without disconnecting them.
By the end of this course, you will fully understand the fundamentals of the Unreal Engine multiplayer framework. You will be able to program your games for multiplayer, no matter the genre. This course will serve you as a reference manual you can refer back to, skipping to lectures specific to each topic for a refresher.
I recommend that all of my students take this course before taking any of my more advanced multiplayer courses!
This course assumes you already understand the basics of Unreal Engine C++. If you have made at least one Unreal Engine C++ project, or you have completed my Unreal Engine 5 C++ - The Ultimate Game Developer Course, you're ready.
Ready to finally understand how multiplayer works in Unreal Engine? It's not difficult! You just have to understand the fundamentals.
I'll see you soon,
Stephen