Multiplayer Replication Basics in Unreal Engine 5 - Make a Multiplayer Game

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments

You make great videos. I look forward to each one

๐Ÿ‘๏ธŽ︎ 5 ๐Ÿ‘ค๏ธŽ︎ u/TheDUDE4029 ๐Ÿ“…๏ธŽ︎ Jan 23 2023 ๐Ÿ—ซ︎ replies

Does this take into account network latency?

๐Ÿ‘๏ธŽ︎ 5 ๐Ÿ‘ค๏ธŽ︎ u/speedtouch ๐Ÿ“…๏ธŽ︎ Jan 23 2023 ๐Ÿ—ซ︎ replies

Nice!

๐Ÿ‘๏ธŽ︎ 5 ๐Ÿ‘ค๏ธŽ︎ u/SelimOzcan ๐Ÿ“…๏ธŽ︎ Jan 22 2023 ๐Ÿ—ซ︎ replies
Captions
what's up guys welcome to new Unreal Engine 5 tutorial and today we'll cover the multiplayer replication Basics it's gonna be a very easy video to follow so let's get started but first check out the link in the description to get out with some Unreal Engine courses on winfox alright so first of all what is actually replication well replication is the core part of networking and its purpose is to synchronize data and procedure codes between clients and servers basically sync the whole game with all the players right all the the positions all the animations the game State the health all about again as you may know the English work then as you may know the English word replicate means like having an exact copy so it's basically that okay all right so let's start covering some examples but first we have to set up the editor to play tests in multiplayer so to do that we can go into the options right uh on here and the three dots right next to the play settings pause and stop and you will see down here we have multiplayer options so first of all we have the number of players so in our case we want to just test with two players okay you know be testing the publication between two of them uh we connect the number low so you know it's just easier for us and now we have the networking mode now this is how the the game will run and and the first thing is Place analog so this basically just means single player okay there's no replication that will be going on so if I know like for example press play you will see that there's two windows opening but there's only one player that nothing is replicating actually uh actually I'm gonna also I change the color mid to medium because I don't know it's consuming a lot of performance guys while I'm recording um but now uh you saw that there were also some more um options of replication let's go here and go into net mode so the next one is uh play as listen server so this will mean that a player will act as a a client and a server at the same time so they will be playing the game and hosting themselves the server as well and now we have players Clan which is basically both players will be kind that connects into an external uh dedicated server okay and the back end is you know created back scenes and and Etc so for today when I used the most common one with this display isolation server so it's one player whole uh hosting the game and I'll also playing the game okay now the other ones play the game so make sure that we can go ahead and press play and now you will see that uh two players appeared but for some reason uh the second player failed well this because we have to go ahead and just duplicate the app player start so go ahead and control D and it's duplicate it just because sometimes if they overlap they will not spawn Etc alright and also make sure that you have here uh default uh Play store okay so now you will see that both players will start and there we go now we have a better way of doing this we just new editor window which will basically just open individual Windows as you can see now uh you may notice that let me just go ahead and make this a bit smaller there we go all right so uh you'll see the one is the client and one is the server so in this case as you can see this is the listen client okay so we're playing the game and hosting the server and then we have the other one which is use decline which is joined into the servers game great so um as you can see uh everything is automatically replicating all the animations the movement Etc and this is because um all the animations and movements are automatically replicated by unreal and this is very handy and Time Saver because uh it just makes it so easy to make uh multiplayer games of course this is the the the basics aspect of it there's many more things that will complicate all the things in the future and you're gonna make a big game and and sync everything okay but overall Unreal Engine will make it very easy for us and just replicate everything okay and movement animation stuff now there's a thing on animations that will not um well there are some things that in animations that will not um replicate automatically and the one that you have to know is use any mounted case Okay as you know in a name montage is use a it's just an animation that you can play from a blueprint you can use call this node and it will play and the thing is that that will not be replicated for example and what we have to do is create on our PC that we'll cover later but let's start by seeing how these players are replicated okay so let's go ahead and next to the game and now if we go into the third person character blueprint um you will see that has some notes over here sorry about that okay you didn't see anything anyway if we go into class Depots and we search for replication or is replica you will see that we have a whole section of application options and parameters and the first one that you will see is well replicate movement so if I were to disable this and compile now if I press play you will see now if I go ahead and move well the other player in the other um on the other instance it's not moving as you can see and it happens with both so literally the movement is not sinking they're not moving okay we're not transferring all the data and Etc so let's go ahead and enable this now of course there's many more options that you don't need to know right now um but now we have another one which is rubber case and this is just the object in general okay and this actor Will replicate or not so now if we compile and disable that you will see the now literally uh in your server they appear but in the clan now and this is just how things works with servers and clients they work a bit differently and you will see later on how they work with rpcs but you can see that the in the client the the thing the actor is not replicated it's not even there but any server is because it respondency itself it's a bit different but basically it's not even there okay so uh you don't want that so you want to replicate this object no there's many cases that you may want to replicate it but there you go and you have things as you know the update frequency and Etc but of course we are not going to touch any of that all right so um let's start by an RPC example now that you know a bit how Unreal Engine replicates his objects the movement Etc let's actually make an RPC now you probably will be wondering well what the hell is an RPC well the RPC is like a message uh in the form of events that a player sends to another player to do something for example if a player attacks and they play in I don't know they they shoot they spawn a product too okay um uh that will automatically not be um replicated by Unreal Engine because then truly goes through different things so um probably that specific bullet isn't instant also in the other reality in the other instances of the player so what we can do is send the event with bad uh spawning projectile to the other players all right it's as simple as that now it probably may sound a bit confusing now but don't worry as we start actually doing it you will probably gonna say much better so let's go ahead don't worry about all that stuff let's find a space and now let's say that for example if I hit the two key I will go ahead and let's make a simple example so I just you know changing the player's mesh material okay so we're gonna change the material of the mesh so let's go ahead and drag the mesh and then set material and then I'm going to set it to be the index one because it's like the chest okay it's like this at the this one which covers more of this here so we can see a bit better and now the material gonna say for example this Pro this purple one which or pink one um which I think more visible so now if I press play without doing anything else uh and if I press Zoom you will see that well okay um the material change but it doesn't compile in shaders let me quickly go and just change the thing so it will compile there we go okay so this green one uh is already compelled okay so um let's put that green one there we go okay the compound so let's delete this player so if I now uh press play you'll see that it doesn't matter if I go to server whatever if I press Zoom the material on our instance will change as we set it to but in the other players reality as you can see the other player did not change and it happens the same invisible so what we had to do is send the RPC that I just mentioned before so to create an RPC we have to create a custom event this right click over here and create custom events so for example we have to name these things very very cleverly because of course if we don't know what they are we don't know what they do so we always have to just name them correctly especially on rpcs because you know as you started to have a bunch of them it'll be hard to find them Etc so for example we can send RBC underscore um you know change material change and now the RPC will actually go ahead and do the uh well the the thing system okay so this is a battery decline doing it the RPC now will do it instead and now we have to select the RBC and change the replicates method so now we want it to be multicast now you will see that we have a few options over here so multicast will basically replicate this event into everyone else okay so uh it will just basically massively send the RPC into everyone okay and then we have run server which will replicate this event on the server so we'll uh if we're a client and we'll go ahead and sign into the server and then don't worry about running an uninclan because this is just yeah happening on your client okay anyway it wants this to be multicast because who wants to change it in all the players so if now I want to press two I call the RPC sorry RPC change material and compile and press play and then go here and then press uh two you'll see that now well we have the green over here changing and now the uh client on the left also changing but now I extended that from the server so if I were to change from the client and press Zoom do you see that it will change in our client but not in the server so you're probably wondering where what just happened why did from the server to the client work but from the client to the server didn't well this is how uh unbrew engine does things and it's always server and authorized so this is just preventing that hackers can change things from the game in the clients and effects other players it's as great and it is just much better so what we have to do is firstly send this RPC into the into the server and then the server would send the RPC to all the clients by multicason so it is as simple as it's creating another RPC um to server server and underscore again and then change material for example okay and now the server will basically just do the RPC change material and now instead of doing the RPC directly we will do the RPC from the server so it might be a bit confusing there's a lot of server clients Etc don't worry when we press 2 we are calling the server to do something the server is going ahead and um calling the RPC into everyone to change the material now we have to do one more thing and I select the custom event on the server and change to run on server so we'll go ahead and call it front server so if I press play you will see the now I can of course do it from Desert to the client but now from the client to server it will also work as you can see so yeah um it is just honestly practicing and practicing uh once you got the concept as we can see over here um it's just doing it doing it and just um getting the trick as you know okay so I had to have to send this to the server and then move to custom into all the clients and so on and so on okay now we have to do you have careful with the rpcs um because they can consume more a lot of uh bandwidth if we are sending for example every frame in the tick frame okay because movement is done in a way that a review engine will replicate it more efficiently and stuff but if we for example launch an RPC and the event take every frame well that's not good because they're a bit less performance optimized I guess we could say okay so you have to be a bit careful but overall you can be safe okay all right so let's do one more last example and it's doing the play animation Montage that I mentioned before so for example we're gonna press a key ma'am for example key three okay and then I'm gonna play an animation so as you may know to play in the name Montage we use Kodi play a name uh Montage note this is decent there's two notes of any monitor it doesn't matter which one you play this is just a simple one okay so now uh we can go ahead and select an animation Montage now in my case I'm just going to choose a very simple animation um we're just gonna be this attack animation so we have to create the animation Mount as you may know uh right click create animantage now if you want and to you know learn more about animation montages and stuff you can go ahead and check out all my tutorials I have lots of them covering animations and all kinds of things so um if you want to check it out go ahead alright so now that we have our animation animation modded uh created we can now call it so here parachute and I'll also as you may know we have to make sure that we have an open the animation blueprint and in the name graph we have a default slot to be able to play DNA monster now I'm not gonna explain that because I have tutors on this and this is your specialized um replication okay anyway so if I now press play and press the three key you'll see that we are pushing on the server but not on the client and the same with the client we are pushing the client but not a server nothing is replicated so again we have to do on our PC right click custom event RPC escort attack a name for example oh that was that has two A's no no no okay there we go oh no it deleted the whole event second there you go uh set the replication into multicast because we want to send it to everyone and then we want to do this play the animation and now we have to do one more thing which is launch it from oh no that's not what we want um because moment here we go uh from the server into everyone so our PC underscore server attack on him and the server will go into running server and then RPC attack NM and then when we press the three key it will call the RPC server attack a name all right so now if I press play um you will see that now if I press three uh in both we are this they will be attacking and also from the uh coin so yeah it's something working everything is syncing as you can see guys if you enjoyed this tutorial I really appreciate if you like the video and subscribe to my channel I have lots of all new engine parts stores so if you want to check it out go ahead and now yes without said bye bye foreign [Music]
Info
Channel: Gorka Games
Views: 35,811
Rating: undefined out of 5
Keywords: games, videojuegos, unreal engine, unreal engine 5, ue5, replication basics, replicate multiplayer, tutorial, quixel, megascans, unreal engine tutorial, multiplayer game, ue5 how to replicate in multiplayer, ue5 make multiplayer game, unreal engine how to replicate online game, unreal engine 5 multiplayer game server, unreal engine 4 replicate, unreal engine 4, ue4, ue5 multiplayer online
Id: ef6SeknakeU
Channel Id: undefined
Length: 17min 17sec (1037 seconds)
Published: Sun Jan 22 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.